nginx版本為1.2.6 thinkphp版本為3.1.2
在nginx下配置thinkphp時,如果需要去除index.php這個默認的路徑名,同時修改web服務對應的目錄,就需要修改nginx下的default.conf這個里面的配置:
- location / {
- root /usr/share/nginx/html/xxxxx;
- index index.php index.html index.htm;
- if (!-e $request_filename)
- {
- rewrite ^(.*)$ /index.php?s=$1 last;
- }
- }
root修改web服務所在文件夾(視個人不同情況),然后抓取獲取的url,通過正則抓取所對應的url:
- location ~ /.php {
- set $script $uri;
- set $path_info "/";
- if ($uri ~ "^(.+/.php)(/.+)") {
- set $script $1;
- set $path_info $2;
- }
- fastcgi_pass 127.0.0.1:9000;
- #fastcgi_index index.php?IF_REWRITE=1;
- include fastcgi_params;
- fastcgi_param PATH_INFO $path_info;
- fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/xxxxx$script;
- fastcgi_param SCRIPT_NAME $script;
- }
最后修改對應的php文件設置path_info修改fastcgi的參數,這樣就可以完成對nginx關于thinkphp去掉index.php的問題.
新聞熱點
疑難解答
圖片精選