thinkphp框架對url有一定的規範,所以如果你希望定製你的url格式的話,就需要好好了解下內建的路由功能了,它能讓你的url變得更簡潔和有文化。首先我們在common/config.php設定為2,即rewrite模式
接著我們在頁面上加乙個導航鏈結,首頁跳轉到index.html,註冊到reg.html,登入到login.html。加上路由的鏈結,就不需要u方法了哦。
接著我們看下路由規則和靜態快取規則
return
array
( 'url_router_on' => true,//
開啟路由
'url_route_rules' => array
( '/^reg/' => 'index/reg',
'/^login/' => 'index/login',
'/^index/' => 'index/index',),
'html_cache_on' => true, //
開啟靜態快取
'html_cache_time' => 3600, //
全域性靜態快取有效期(秒)
'html_file_suffix' => '.html', //
設定靜態快取檔案字尾
'html_cache_rules' => array(//
定義靜態快取規則
// 定義格式1 陣列方式
'index:' => array('index/'),//
控制器,方法
),);
最後發下素材火的路由和靜態快取規則,僅供參考。
'url_router_on' => true,
'url_route_rules' => array
( 'templates/:id\d' => 'templates/detail',
'templates/:paras' => 'templates/index',
'js/:id\d' => 'js/detail',
'js/:paras' => 'js/index',
'php/:id\d' => 'php/detail',
'php/:paras' => 'php/index',
'source/:id\d' => 'source/detail',
'source/:paras' => 'source/index',
'site/:id\d' => 'site/detail',
'site/:paras' => 'site/index',
'search' => 'search/templates',
'forget' => 'pwd/find',
'sendtip' => 'pwd/send_tip',
'help/template_post' => 'help/template_post',
'help/:paras' => 'help/index',
'space/uid/:id\d' => 'space/index',
'psd/:id\d' => 'psd/detail',
'psd/:paras' => 'psd/index',
'answer/:id\d' => 'answer/detail',
'answer/:paras' => 'answer/index',),
'html_cache_time' => 10000, //
全域性靜態快取有效期(秒)
'html_file_suffix' => '.html', //
設定靜態快取檔案字尾
'html_cache_rules' => array(//
定義靜態快取規則
'templates:' => array('templates/_'),
'js:' => array('js/_'),
'php:' => array('php/_'),
'site:' => array('site/_'),
'psd:' => array('psd/_'),
'answer:' => array('answer/_'),
'search:' => array('search/'),
'help:' => array('help/'),
'login:' => array('login/index'),
'reg:' => array('reg/index'),
'index' => array('index/index')
)
動態路由和靜態路由
靜態路由 靜態路由是由管理員在路由器中手動配置的固定路由,路由明確地指定了包到達目的地必須經過的路徑,除非網路管理員干預,否則靜態路由不會發生變化。靜態路由不能對網路的改變作出反應,所以一般說靜態路由用於網路規模不大 拓撲結構相對固定的網路。靜態路由特點 1 它允許對路由的行為進行精確的控制 2 減...
Django 路由 配置和靜態檔案簡介
路由 配置檔案 靜態檔案 一 url配置 二 配置檔案 三 靜態檔案 回到頂部 一 url配置 1.url的配置過程 2.注意點 django預設url配置風格,實在使用者訪問的路徑後面加 使用者在主路由檔案中,定義包含規則的時候,最好加上反斜槓,這樣使用者訪問 index 或者 index 均能訪...
ubuntu配置網路和靜態路由 介面配置形式
目錄靜態路由 本文主要針對ubuntu18.0系統進行介面形式配置網路。並配置靜態路由。開啟設定 網路 按照分配的靜態ip進行正確的配置 完成之後點選 應用 不要忘記關閉重啟 伺服器存在雙網絡卡並且需要內外網同時訪問,需要進行如下配置 示例 檢視靜態路由 ping 100.3.4.160 失敗 靜態...