ThinkPHP 路由介紹

來源:互聯網
上載者:User

   ThinkPHP 支援 URL 路由功能,要啟用路由功能,需要設定ROUTER_ON參數為true。開啟路由功能後,系統會自動進行路由檢測,如果在路由定義裡面找到和當前URL匹配的路由名稱,就會進行路由解析和重新導向。路由功能需要定義路由定義檔案,位於項目的配置目錄下面,檔案名稱為 routes.php

定義格式:  Return Array(         ‘RouteName’=>array(‘模組名稱’,’操作名稱’,’參數定義’,’額外參數’), //常規路由  );例如,我們啟用了路由功能,並且定義了下面的一個路由規則:
‘blog’=>array(‘Blog’,’index’,’year,month,day’,’userId=1&status=1’)
那麼我們在執行 <A href="http://<severName>/appName/blog/2007/9/15">http://<severName>/appName/blog/2007/9/15的時候就會實際執行 Blog 模組的 index 操作,後面的參數/2007/9/15/ 就會依次按照 year/month/day 來解析,並且會隱含傳入 userId=1 和 status=1 兩個參數。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.