原來只想在域名conf中加上路由重定向
location / {
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=$1 last;
break;
}
}
但是請求地址出現(xiàn)了 Access denied,各種操作后得出比較精簡的配置如下:
- 修改 /usr/local/php/etc/php.ini
#cgi.fix_pathinfo由0改為1
- 修改 域名conf
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
#添加TP5的三個配置
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
如果只添加TP5的三個配置(主要是
fastcgi_split_path_info ^(.+\.php)(/.+)$;),請求網(wǎng)址出現(xiàn)循環(huán)請求的bug,嚇?biāo)朗迨辶?/p>