thinkphp nginx設定rewrite,位址會多出個.php
,http://localhost:7080/.php?m=...
nginx設定檔
server
{
listen 80;
#listen [::]:80;
server_name localhost 192.168.150.79 doc.mall.com;
index index.html index.htm index.php default.html default.htm default.php;
root /data/www/wwwroot/mall_doc;
#error_page 404 /404.html;
location / {
if (!-e $request_filename)
{
rewrite ^/index.php(.*)$ /index.php?s= last;
rewrite ^(.*)$ /index.php?s= last;
rewrite ^/(.*)$ /index.php/;
}
}
location ~ .php {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name ;
set $path_info ;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log /data/www/wwwlogs/doc.mall.access_log;
}
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
rewrite ^/ (.*)$ /index.php/$1;
這三種方式都試過了
'URL_MODEL' => 2,
php版本為PHP 7.1.5
nginx版本為:nginx/1.12.0
大家有麼碰到這種狀況?
php版本在5.6.9上是正常存取
之前我配置THINKCMF的時候也出現過這個問題
後來找到問題是這個$_SERVER['SCRIPT_NAME'] 常數中的路徑出現問題有2個解決放過
1.你修改常數中的資料
2.使用APACHE
目前就想到這2個方法
另外可以追蹤我的部落格PHP程式設計師學習筆記
雷雷