我的根文件夹中有两个文件:main.html
和index.php
。 那么,通常index.php
发生的地方,因为它有更高的优先级响应,只是想改变逻辑,所以,首先用户必须访问main.html
,然后重定向到index.php
。我在我的.htaccess
中尝试了下面的代码,但它不能如我所料。实际上,在这样做之后,现在第一页已正确更改为main.html
,但它永远不会被重定向到index.php!它实际上返回main.html
连连(如循环!).htaccess和DirectoryIndex
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
DirectoryIndex main.html /main.html
PS:
1 - 即使我尝试请求的index.php它会打开main.html中,而不是!
感谢您的回复,所以我提到它是通过将DirectoryIndex添加到htaccess文件中完成的,但问题是该页面永远不会被重定向到index.php(我使用了相同的javascript)。它实际上又返回到main.html ...我想它与我在htaccess中使用的RewriteRules有关。请注意,我仍然需要该部分来处理网站中的固定链接。 – atari83
只是一个小问题:这两个脚本的处理方式是否与Web服务器的处理方式不同:window.location =“http://www.coolsite.com/index.php”;和window.location =“index.php”; ?我问这个,因为现在我已经用第二个代码做了这个。 – atari83
同样的问题,我想:http://serverfault.com/questions/469339/static-site-to-dynamic-rewrite-loop – atari83