這篇文章將為大家詳細(xì)講解有關(guān)tp怎么隱藏index.php,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
tp隱藏“index.php”的方法:首先找到并打開“/public/.htaccess”文件;然后根據(jù)php環(huán)境分別設(shè)置“.htaccess”文件;最后保存修改即可。
TP5隱藏index.php
一,找到/public/.htaccess文件,如果你的入口文件已經(jīng)移動到根目錄下,那么你的.htaccess文件也要剪切到根目錄下,總之要確保.htaccess跟入口的index.php保持同級。
二,根據(jù)你的php環(huán)境分別設(shè)置.htaccess文件:
Apache:
Options +FollowSymlinks -Multiviews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
phpstudy:
Options +FollowSymlinks -Multiviews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
Nginx(在Nginx.conf中添加):
location / { // …..省略部分代碼 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } }
關(guān)于tp怎么隱藏index.php就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。