nginx上布置thinkphp
thinkphp config配置:
\'URL_MODEL\' => \'2\', //URL模式
nginx rewrite配置:
location / {
set $static 0;
if ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
root /data/www;
set $static 1;
}
if (!-e $request_filename){
set $static 0$static;
}
if ($static = 00){
rewrite ^/(.*)$ /index.php?s=$1 last;
}
}
如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称
location /yourdomain/ {
set $static 0;
if ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
root /data/www;
set $static 1;
}
if (!-e $request_filename){
set $static 0$static;
}
if ($static = 00){
rewrite ^/yourdomain/(.*)$ /yourdomain/index.php?s=$1 last;
}
}
版权声明:本文为wuxie1989原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。