溫馨提示×

溫馨提示×

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

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

thinkphp去除index.php的方法

發(fā)布時間:2020-12-10 10:10:23 來源:億速云 閱讀:553 作者:小新 欄目:編程語言

這篇文章主要介紹thinkphp去除index.php的方法,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!

thinkphp去除index.php的方法:首先加載mod_rewrite.so模塊;然后將AllowOverride None中的None改為all;最后將htaccess文件放到根目錄下即可。

Thinkphp中去除URL里的index.php

例如你的原路徑是 http://localhost/test/index.php/index/add

那么現(xiàn)在的地址是 http://localhost/test/index/add

如何去掉index.php呢?

1.httpd.conf配置文件中加載了mod_rewrite.so模塊 //在APACHE里面去配置

#LoadModule rewrite_module modules/mod_rewrite.so把前面的警號去掉

2.AllowOverride None 講None改為 All //在APACHE里面去配置

<Directory "D:/server/apache/cgi-bin">
AllowOverride none 改 AllowOverride ALL
Options None
Order allow,deny
Allow from all
</Directory>

3.確保URL_MODEL設(shè)置為2,

在項目的配置文件里寫

return Array(
'URL_MODEL' => '2',
);

4 .htaccess文件必須放到跟目錄下

這個文件里面加:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

補充:在windows下不能建立以點開頭的文件,你可以先隨便建立一個文件

然后在DOS在操作 rename xxxx.xxxx .htaccess

或者打開記事本寫入htaccess然后另存為.htaccess即可

如果出現(xiàn)403錯誤則將.htaccess打開在開頭添加Options +FollowSymlinks

即:

Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

即可解決.

無權(quán)限也是加上Options +FollowSymlinks

以上是“thinkphp去除index.php的方法”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(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進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI