.htaccess redirect permanent www.domain.com/A to www.domain.com/A/B

为君一笑 提交于 2019-12-24 09:37:26

问题


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

The hierarchy comes from the Apostrophe CMS.

The following rule does not work in .htaccess:

Redirect permanent /A http://www.domain.com/A/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


回答1:


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

EDIT: 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


来源:https://stackoverflow.com/questions/5010208/htaccess-redirect-permanent-www-domain-com-a-to-www-domain-com-a-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!