可以通過URL重寫隱藏應用的入口文件index.php
,下面是相關服務器的配置參考:
【Apache】
- httpd.conf配置文件中加載了mod_rewrite.so模塊
- AllowOverride None 將None改為 All (PS:所有的AllowOverride對應的None都改為ALL)
- 把下面的內容保存為.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就可以了。