gpt4 book ai didi

.htaccess 301 重定向将旧网址传递到新网址

转载 作者:行者123 更新时间:2023-12-02 21:47:35 25 4
gpt4 key购买 nike

我将一些静态 html 文件/url 重定向到一些新的 url,如下所示:

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/

为什么我的网址重定向会沿旧路径传递?

最佳答案

事实证明,这只是一个优先顺序。看来第一条规则:

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 作为参数传递。但通过颠倒顺序,它是一个更明确的匹配,然后优先,因为它位于它尝试匹配的 URL 列表的顶部。

不确定我是否正确解释了这个逻辑/操作顺序,但这是我在凌晨 4 点能总结这个功能的最好结果 =)

关于.htaccess 301 重定向将旧网址传递到新网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19265940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com