.htaccess 中的索引文件
在我的 htaccess 文件中,我有以下重定向:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteRule index.html$ Controller/index.php [L]
</IfModule>
我希望将 index.html (不存在)重定向到我的控制器。 index.php(存在)应该是我的主页。
现在,在浏览器中输入 http://www.domain.com/ 时,我的主页无法正常工作。该 URL 重定向到我的控制器。 http://www.domain.com/index.php 工作正常,带来了我的主页。
如何将 index.php 设置为索引文件以保持控制器的重定向?
In my htaccess file I have the following redirections:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteRule index.html$ Controller/index.php [L]
</IfModule>
I want index.html (which does not exist) to be redirected to my controller.
index.php (which exists) should be my home page.
Now, my homepage is not working when typing http://www.domain.com/ in my browser. That URL redirects to my controller.
http://www.domain.com/index.php works fine, bringing my homepage.
How do I set index.php as my index file keeping my redirection for the controller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解了您的情况,您只需指定
DirectoryIndex
在您的.htaccess
文件中,以便它仅指向index.php
:在该规则和您的规则之间,会导致以下结果URL 到文件的映射:
If I've understood your situation correctly, you just want to specify
DirectoryIndex
in your.htaccess
file so that it only points toindex.php
:Between that and your rules, that leads to the following URL to file mappings: