linux服務器中Apache隱藏index.php失敗


可以通過URL重寫隱藏應用的入口文件index.php,下面是相關服務器的配置參考:

【Apache】

  1. httpd.conf配置文件中加載了mod_rewrite.so模塊
  2. AllowOverride None 將None改為 All (PS:所有的AllowOverride對應的None都改為ALL)
  3. 把下面的內容保存為.htaccess文件放到應用入口文件的同級目錄下
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on

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

以上操作全部都完成,重啟apache后還是失敗,原因在與include的【httpd-vhosts.conf】中配置沒有改成允許URL重寫。

只需將

DocumentRoot "F:/wamp/www/test"

ServerName www.test.com

ServerAlias admin.tpshop.com

DirectoryIndex index.html index.htm index.php

Options FollowSymLinks

AllowOverride none

Order allow,deny

Allow from all

 

改成

DocumentRoot "F:/wamp/www/test"

ServerName www.test.com

ServerAlias admin.tpshop.com

DirectoryIndex index.html index.htm index.php

Options FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

 

然后保存,重啟apache就可以了。


免責聲明!

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



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