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

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

【Apache】html

  1. httpd.conf配置文件中加載了mod_rewrite.so模塊
  2. AllowOverride None 將None改成 All (PS:全部的AllowOverride對應的None都改成ALL)
  3. 把下面的內容保存爲.htaccess文件放到應用入口文件的同級目錄下

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#若是頁面出現"No input file specified." 請註釋第一條,啓用第二條
RewriteRule ^(.*)$ $1.php [QSA,PT,L]
#RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
#RewriteRule ^(.*)$ index.php [E=PATH_INFO:$1,QSA,PT,L] 
</IfModule>apache

以上操做所有都完成,重啓apache後仍是失敗,緣由在與include的【httpd-vhosts.conf】中配置沒有改爲容許URL重寫。服務器

只需將ide

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

改爲spa

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就能夠了。code

相關文章
相關標籤/搜索