我将一些静态html文件/网址重定向到这样的新网址:
Redirect 301 / http://newsite.com
Redirect 301 /pageA.html http://newsite.com/subfolder/page-a/
Redirect 301 /pageA-B.html http://newsite.com/subfolder/page-a/page-b/
但是,生成的url看起来像这样:
http://newsite.com/subfolder/pageA-B.html/
而不是
http://newsite.com/subfolder/page-a/page-b/
为什么我的网址重定向会沿着旧路径传递?
答案 0 :(得分:4)
事实证明,这只是一个优先顺序。似乎是第一条规则:
Redirect 301 / http://newsite.com
立即成为一个全能的。相反,订单需要颠倒过来:
Redirect 301 /pageA-B.html http://newsite.com/subfolder/page-a/page-b/
Redirect 301 /pageA.html http://newsite.com/subfolder/page-a/
Redirect 301 / http://newsite.com
从我收集的内容来看,我的原始方式看到根目录下的任何路径都自动匹配根,因为它本来就是传递旧URL作为参数。但是通过颠倒顺序,这是一个更明确的匹配,然后优先,因为它位于它试图匹配的网址列表的顶部。
不确定我是否正确解释了这种逻辑/操作顺序,但这是我能在凌晨4点总结此功能的最佳方法=)