Nginx環境
在Nginx低版本中,是不支持PATHINFO的,但是可以通過在Nginx.conf中配置轉發規則實現:
- location / { // …..省略部分代碼
- if (!-e $request_filename) {
- rewrite ^(.*)$ /index.php?s=$1 last;
- break;
- }
- }
其實內部是轉發到了ThinkPHP提供的兼容模式的URL,利用這種方式,可以解決其他不支持PATHINFO的WEB服務器環境.
如果你的ThinkPHP安裝在二級目錄,Nginx的偽靜態方法設置如下,其中youdomain是所在的目錄名稱.
- location /youdomain/ {
- if (!-e $request_filename){
- rewrite ^/youdomain/(.*)$ /youdomain/index.php?s=$1 last;
- }
- }
舉個例子
-
location /tp/public/ {index index.html index.htm index.php l.php;autoindex off;if (!-e $request_filename) {rewrite ^/tp/public/(.*)$ /tp/public/index.php?s=/$1 last;break;}