1. 程式人生 > >linux服務器中Apache隱藏index.php失敗

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

document mod write inux override director tee family height

可以通過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就可以了。

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