htaccess的重定向永久www.domain.com/A到www.domain.com/A/B重定向、htaccess、www、com

2023-09-02 10:03:23 作者:原宿风i

一个是一个空文件夹,只是用于建立我的页面层次结构。 它包含B,C这也是文件夹(非空)

A is an empty folder, simply used for building up my hierarchy of pages. It contains B,C which are also folders (non empty)

层次结构来源于撇CMS

下面的规则不会在.htaccess工作:

The following rule does not work in .htaccess:

Redirect permanent /A http://www.domain.com/A/B

,因为它最终于: http://www.domain.com/ A / B / B / B / B 等,因为规则被调用一遍又一遍。

because it ends up to : http://www.domain.com/A/B/B/B/B etc since the rule is invoked over and over.

任何人都可以点我一个解决方案吗? 谢谢

Can anyone point me to a solution ? Thanks

推荐答案

尝试使用RedirectMatch,包括$的正则表达式的字符串结尾。

Try using RedirectMatch and include the "end of string" $ in the regex.

RedirectMatch permanent /A$ http://www.domain.com/A/B
RedirectMatch permanent /A/$ http://www.domain.com/A/B

编辑:下面的比赛可能会工作更好一些(全部)

The below matches may work somewhat better (at all)

RedirectMatch permanent .*/A$ http://www.domain.com/A/B
RedirectMatch permanent .*/A/$ http://www.domain.com/A/B