index.php 重定向的正则表达式(但有点复杂!)
您好,感谢您查看此内容。我有一个问题,需要重定向: www.thisdomain.com/index.php 到: www.thisdomain.com/
但是...
由于我有两个index.php 文件,情况变得很复杂。这里一: www.thisdomain.com/index.php 这里有一个: www.thisdomain.com/a_forum/a_forum_submission/index.php
所以,我会使用的正常 301 重定向是:
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.thisdomain.co.uk/$1 [R=301,L]
问题是,这也会重定向较低级别的 index.php,直接返回到不需要的路由。
所以,我想要实现的是将 www.thisdomain.com/index.php 重定向到根目录,但不将 www.thisdomain.com/a_forum/a_forum_submission/index.php 重定向到根目录。
如果您能帮助我,我将非常感激。我已经尝试了我所知道的一切,但我的正则表达式知识让我失望。
再次感谢,
D
Hello and thanks for looking at this. I have an issue in that I need to redirect:
www.thisdomain.com/index.php
to:
www.thisdomain.com/
BUT...
this is complicated by the fact that I have two index.php files. One here:
www.thisdomain.com/index.php
and one here:
www.thisdomain.com/a_forum/a_forum_submission/index.php
So, the normal 301 redirect I would use is:
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.thisdomain.co.uk/$1 [R=301,L]
The problem is that this will redirect the lower level index.php as well, right back up to the route which is not desired.
So, what I want to achieve is redirecting www.thisdomain.com/index.php to the root, but WITHOUT redirecting www.thisdomain.com/a_forum/a_forum_submission/index.php to the root.
If you can help me out, I'd really appreciate it. I've tried everything I know of, but my regular expression knowledge is letting me down.
Thanks again,
D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
取出通配符匹配表达式
(。*)
:应该做您要寻找的事情。这样,您甚至可能不需要
rewriteCond
Take out the wildcard match expression
(.*)
:Should do what you are looking for. With this, you may not even need the
RewriteCond
我认为解决的更简单的方法是在 www.thisdomain.com/a_forum/a_forum_submission/ 内创建一个 .htaccess 文件,覆盖 rewritecond 或停用重写模块。
The easier way that I think of solving is creating a .htaccess file inside www.thisdomain.com/a_forum/a_forum_submission/ overwriting that rewritecond or deactivating the rewrite module.
简单地做:
不过不需要重写条件。
祝你今天过得愉快。
Simply do:
No need for the rewrite condition, though.
Have a nice day.
尝试
Try