溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

lnmp如何隱藏index.php

發(fā)布時間:2022-10-24 16:37:00 來源:億速云 閱讀:108 作者:iii 欄目:編程語言

這篇文章主要介紹“l(fā)nmp如何隱藏index.php”的相關(guān)知識,小編通過實際案例向大家展示操作過程,操作方法簡單快捷,實用性強(qiáng),希望這篇“l(fā)nmp如何隱藏index.php”文章能幫助大家解決問題。

lnmp隱藏index.php的方法:1、打開“l(fā)ocation ~ [^/].php”文件;2、修改內(nèi)容為“l(fā)ocation ~ [^/].php”;3、去掉“#try_files $uri =404;”前面的#符號;4、添加“rewrite "^/(.*)$" /index.php last;”內(nèi)容;5、重啟Nginx即可。

lnmp 怎么隱藏index.php?

lnmp啟用pathinfo并隱藏index.php

編輯如下區(qū)段:

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;
    include fastcgi.conf;
    #include pathinfo.conf;
}

第1行改為:

location ~ [^/].php

第4行注釋掉, 即前面加#

#try_files $uri =404;

去掉第8行的注釋

include pathinfo.conf;

在location ~ [^/].php 上面添加區(qū)段

location /
{
    if (!-e $request_filename)
    {
        rewrite "^/(.*)$" /index.php last;
    }
}

重啟Nginx

service nginx restart

關(guān)于“l(fā)nmp如何隱藏index.php”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識,可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會為大家更新不同的知識點。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI