nginx下Thinkphp 隱藏index.phpphp
php.ini配置:nginx
ccgi.fix_pathinfo=0 改成 cgi.fix_pathinfo=1thinkphp
thinkphp config配置:服務器
'URL_MODEL' => '2', //URL模式unix
nginx rewrite配置:code
location / { if (!-e $request_filename) { rewrite ^/index.php(.*)$ /index.php?s=$1 last; rewrite ^(.*)$ /index.php?s=$1 last; break; } }
location ~ .php { #原有代碼 # try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; #設置PATH_INFO並改寫SCRIPT_FILENAME,SCRIPT_NAME服務器環境變量 set $fastcgi_script_name2 $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") { set $fastcgi_script_name2 $1; set $path_info $2; } fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2; fastcgi_param SCRIPT_NAME $fastcgi_script_name2; }