首頁 >後端開發 >php教程 >lnmp啟用pathinfo並隱藏indexphp

lnmp啟用pathinfo並隱藏indexphp

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-07-29 09:13:18983瀏覽

編輯如下區段:

location ~ [^/]\.php(/|$)
{       
    # comment try_files $uri =404; to enable pathinfo
    try_files $uri =404;
    fastcgi_pass  unix:/tmp/php-cgi.sock;
    fastcgi_index index.php;
    <strong>include</strong> fastcgi.conf;
    #<strong>include</strong> pathinfo.conf;
} 

第1行改為:
location ~ [^/]\.php
第4行註解掉, 即前面加#
#try_files $uri =404;
去掉第8行的註解
<strong>include</strong> pathinfo.conf;
在location ~ [^/].php 上面新增區段重新啟動Nginx
location /
{
    if (!-e $request_filename)
    {
        rewrite "^/(.*)$" /index.php last;
    }
}
重啟Nginx
service nginx restart
重啟Nginxrrreee rrreee

以上就介紹了lnmp啟用pathinfo並隱藏indexphp,包含了include方面的內容,希望對PHP教學有興趣的朋友有幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn