2013-03-13 38 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