(Yaf >=1.0.0)
Yaf_Router锟角憋拷准锟侥匡拷锟铰凤拷锟�.路锟斤拷锟斤拷一锟斤拷锟矫碉拷URI锟剿点(URL锟叫碉拷URI锟斤拷一锟斤拷锟街o拷然锟斤拷纸锟斤拷锟斤拷锟矫碉拷锟斤拷一锟斤拷module, controller, 锟斤拷action锟斤拷要锟斤拷锟斤拷锟斤拷锟斤拷module, controller, 锟斤拷action锟斤拷锟斤拷锟斤拷一些锟斤拷锟斤拷锟侥诧拷锟斤拷锟角达拷锟斤拷锟揭伙拷锟�Yaf_Request_Abstract锟侥讹拷锟斤拷锟叫o拷然锟斤拷通锟斤拷Yaf_Dispatcher锟斤拷锟斤拷锟斤拷摹锟铰凤拷锟街伙拷锟斤拷锟揭伙拷锟�:锟斤拷锟斤拷拥锟斤拷锟斤拷锟斤拷锟斤拷诘锟揭伙拷锟絚ontroller锟街凤拷之前锟斤拷 Yaf_Router 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞癸拷么锟絇HP锟结构锟斤拷锟斤拷锟狡癸拷锟斤拷模锟斤拷锟斤拷锟阶拷锟斤拷锟斤拷浅锟斤拷锟缴拷幕锟斤拷锟絉uby on Rails锟斤拷路锟缴o拷锟斤拷锟揭诧拷锟斤拷要锟斤拷锟斤拷前锟斤拷知锟斤拷webserver URL锟斤拷转锟斤拷锟斤拷锟街讹拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷Apache 锟斤拷转模锟斤拷墓锟斤拷锟揭伙拷锟斤拷锟� Yaf_Router锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟絤od_rewrite
Example #1 Apache锟斤拷锟斤拷转锟斤拷锟斤拷
RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|css|html)$ index.php
Example #2 Apache锟斤拷锟斤拷转锟斤拷锟斤拷
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L]
Example #3 Lighttpd锟斤拷锟斤拷转锟斤拷锟斤拷
url.rewrite-once = ( ".*\?(.*)$" => "/index.php?$1", ".*\.(js|ico|gif|jpg|png|css|html)$" => "$0", "" => "/index.php" )
Example #4 Nginx锟斤拷锟斤拷转锟斤拷锟斤拷
server { listen ****; server_name yourdomain.com; root document_root; index index.php index.html; if (!-e $request_filename) { rewrite ^/(.*) /index.php/$1 last; } }
Yaf_Router预锟斤拷锟斤拷一锟斤拷默锟斤拷路锟缴o拷锟斤拷锟斤拷锟斤拷controller/action锟斤拷锟斤拷式匹锟斤拷URIs锟斤拷锟斤拷锟解,一锟斤拷module锟斤拷锟斤拷锟街匡拷锟皆憋拷指锟斤拷为锟斤拷一路锟斤拷元锟截o拷锟斤拷锟斤拷URIs锟斤拷锟斤拷为module/controller/action锟斤拷锟斤拷式锟斤拷锟斤拷锟斤拷锟揭诧拷锟狡ワ拷锟揭恍︰RI锟叫讹拷锟解附锟接的诧拷锟斤拷锟斤拷默锟斤拷锟斤拷式锟斤拷controller/action/var1/value1/var2/value2锟斤拷
Note:
Module锟斤拷锟斤拷锟街憋拷锟斤拷要锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫o拷锟斤拷application.module="Index,Foo,Bar"锟斤拷锟皆o拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷拢锟斤拷锟斤拷锟絠ndex, foo 锟斤拷 bar锟杰憋拷锟斤拷锟斤拷锟斤拷为为一锟斤拷module锟斤拷锟斤拷锟狡★拷锟斤拷锟矫伙拷锟斤拷锟斤拷锟斤拷锟斤拷募锟斤拷卸锟斤拷澹拷锟矫碮af使锟斤拷默锟较碉拷module锟斤拷锟斤拷"Index"锟斤拷
锟斤拷锟狡ワ拷锟斤拷锟叫┞凤拷傻锟揭恍╋拷锟斤拷樱锟�
Example #5 Yaf_Route_Static(default route)example
// Assuming the following configure: $conf = array( "application" => array( "modules" => "Index,Blog", ), ); Controller only: http://example/news controller == news Action only(when defined yaf.action_prefer=1 in php.ini) action == news Invalid module maps to controller name: http://example/foo controller == foo Module + controller: http://example/blog/archive module == blog controller == archive Module + controller + action: http://example/blog/archive/list module == blog controller == archive action == list Module + controller + action + params: http://example/blog/archive/list/sort/alpha/date/desc module == blog controller == archive action == list sort == alpha date == desc