如果是一级目录 例如 www.baidu.com/index.php
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
注意如果是二级目录例如 www.baidu.com/aaa/index.phplocation /aaa/ {
if (!-e $request_filename){
rewrite ^/aaa/(.*)$ /youdomain/index.php?s=$1 last;
}
}
该配置在nginx.conf server中 以下是我配置部分location = /500.html {
root /usr/share/nginx/html;
}
location /sgb/{#这里是支持pathinfo的关键地方
if (!-e $request_filename) {
# rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^/sgb/(.*)$ /index.php?s=$1 last;
break;
}
}
thinkphp 代码方面 把'URL_MODEL' => 1, //启用rewrite
路由功能就可以使用了