htaccess的重定向永久www.domain.com/A到www.domain.com/A/B [英] .htaccess redirect permanent www.domain.com/A to www.domain.com/A/B

查看:178
本文介绍了htaccess的重定向永久www.domain.com/A到www.domain.com/A/B的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个是一个空文件夹,只是用于建立我的页面层次结构。 它包含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

这篇关于htaccess的重定向永久www.domain.com/A到www.domain.com/A/B的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆