2013-03-13 27 views
2

如何使用.htaccess調用不同的索引文件?如何使用.htaccess調用不同的索引文件

我需要把我的網站上的鏈接,我需要加載主頁,但與不同的索引文件(index2.html),但網址是www.mysite.com而不是www.mysite.com/index2.html

RewriteEngine On 

RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com\index2.html$ [NC] 
RewriteRule ^$ /index2.php [L] 

上面的規則沒有工作。

回答

0
DirectoryIndex newfile.php newfile.html site-down.php 

應該做的伎倆在.htaccess

+0

怎麼辦? – marius 2013-03-13 13:56:08

+0

只是寫這行到一個新的.htaccess文件應該工作,我沒有嘗試實際上,我使用nginx,但據我記得,它就像這樣在Apache。不需要rewritecond和rewriterule來做到這一點。 – sinanislekdemir 2013-03-13 14:04:00

+0

我試試。它沒有工作。我需要訪問myiste.com/index2.html來加載index2.html內容,但在瀏覽器網址上僅查看www.mysite.com而不是myiste.com/index2.html – marius 2013-03-13 14:06:28

0

我想你要找的是不可能的htaccess的,它完全基於瀏覽器的..所以在index2.html文件中添加這個身體,這是HTML5,所以我不確定它是否在ie9下工作。

<script> window.history.replaceState('Object', 'Title', '/'); </script> 
+0

我在粘貼代碼時沒有任何結果。此人有同樣的問題,我不明白他是如何解決它http://stackoverflow.com/questions/12312906/how-to-call-different-index-files-for-main-domain-and-sub-domins – marius 2013-03-13 14:23:19