ThinkPHP在app/Conf/config.php可以配置URL_MODEL选项,有三种类型:
1. URL_MODEL => 1,默认支持pathinfo
2. URL_MODEL => 2,url重写模式,通过配置url重写来实现
3. URL_MODEL => 3,URL兼容模式,需要生成URL的地方采用U方法动态生成
这里,我们选择2,配置url重写模式,然后配置nginx:
# 在server段location /加载此内容
location / {
if ( !-e $request_filename ) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}