Ubuntu-server 下Apache2 配置.htaccess 隱藏thinkPHP項目index.php


需要開啟Apache2的rewrite模塊

1、打開/etc/apache2/apache2.conf

將文件中的AllowOverride None改為AllowOverride All

 

2、修改mods-enable配置,添加一個軟件鏈接

cd /etc/apache2/mods-enable
ln -s ../mods-avaiable/rewrite.load  rewrite.load

 

3、在項目根目錄下添加.htaccess文件,修改rewrite規則

<IfModule mod_rewrite.c>
RewriteEngine on

#不顯示index.php

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

</IfModule>

 

4、重啟服務器

service apache2 restart

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM