index.php 重定向的正则表达式(但有点复杂!)

发布于 2024-10-02 01:59:46 字数 646 浏览 0 评论 0原文

您好,感谢您查看此内容。我有一个问题,需要重定向: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

走过海棠暮 2024-10-09 01:59:46

取出通配符匹配表达式(。*)

RewriteCond %{THE_REQUEST} ^index\.php
RewriteRule ^index\.php$ http://www.thisdomain.co.uk/$1 [R=301,L]

应该做您要寻找的事情。这样,您甚至可能不需要rewriteCond

Take out the wildcard match expression (.*):

RewriteCond %{THE_REQUEST} ^index\.php
RewriteRule ^index\.php$ http://www.thisdomain.co.uk/$1 [R=301,L]

Should do what you are looking for. With this, you may not even need the RewriteCond

浅笑依然 2024-10-09 01:59:46

我认为解决的更简单的方法是在 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.

ˉ厌 2024-10-09 01:59:46

简单地做:

RewriteRule ^index\.php http://www.thisdomain.co.uk/ [R=301,L]

不过不需要重写条件。

祝你今天过得愉快。

Simply do:

RewriteRule ^index\.php http://www.thisdomain.co.uk/ [R=301,L]

No need for the rewrite condition, though.

Have a nice day.

又爬满兰若 2024-10-09 01:59:46

尝试

 Redirect 301 /index.php http://www.thisdomain.com

Try

 Redirect 301 /index.php http://www.thisdomain.com
凉城已无爱 2024-10-09 01:59:46
RewriteRule ^index\.php(.*) http://www.thisdomain.co.uk/$1 [R=301,L]
RewriteRule ^index\.php(.*) http://www.thisdomain.co.uk/$1 [R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文