需要的功能:
访问的URL: www.x.com/download/123.htm ,
如果download模块存在(判断的标志是存在download文件夹以及index.php)
则rewrite到www.x.com/download/index.php,
否则就rewrite到www.x.com/index.php。
set $module_name /index.php;
if ( $request_uri ~ ^/(\w+)/) {
set $module_name /$1/index.php;
}
if ( !-e $document_root$module_name){
set $module_name /index.php;
}
rewrite . $module_name;
友情提示:用rewrite把nginx配置文件中的变量附加到php文件后面的参数里,然后用var_dump($_GET);帮助很大。
Follow Me