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; } }