2013-04-03 42 views

回答

22

的.htaccess文件裏面工作,您只需要在home.phpDirectoryIndex,使之工作。請記住,這是你的根項目的.htaccess文件中使用:

DirectoryIndex home.php 
+3

它適用於所有子文件夾。我只想僅應用於根文件夾。 – CodeManiac

10

您需要AllowOverride +Indexeshttpd.conf能在.htaccess使用DirectoryIndex

除非是,絕對最簡單的方法來重定向(無根訪問Apache的配置和模塊)是把這個作爲index.html

<!doctype html> 
<html> 
    <head> 
    <meta http-equiv="Refresh" content="0; url=home.php"> 
    </head> 
    <body> 
    </body> 
</html> 
+2

不錯的解決方案... – Dev

-2

只是嘗試重寫/index.html/index.php/home.php

Options +FollowSymlinks 
RewriteEngine on 

RewriteCond %{REQUEST_URI} ^/index\.(html|php) 
RewriteRule ^(.*) /home.php 
+0

我想,http://stackoverflow.com/a/15779237/2007055是正確的。 – 5ervant

1

DirectoryIndex指令適用於所有的子文件夾,如果你想爲每個目錄設置不同的文件,你可以使用mod-rewrite。

要設置/file.html作爲根目錄處理,你可以在你的htaccess的頂部使用:

RewriteEngine on 
RewriteRule ^$ /file.html [L] 

要設置不同勢文件作爲指數的子文件夾,使用此:

RewriteEngine on 
RewriteRule ^subfolder/$ /myfile.html [L] 
相關問題