首页 > 解决方案 > 如何修复此 URL 的 301 重定向

问题描述

我正在尝试转移

www.old.example/ecards/birthday-ecards/all

不再存在

https://www.new.example/static-ecards/company-birthday-ecards.html

使用.htaccess完成此操作时,我将其重定向到

https://www.new.example/static-ecards/company-birthday-ecards.htmlecards/birthday-ecards/all

所以它将它添加到ecards/birthday-ecards/all不需要的 URL 的末尾。

我是这个菜鸟,而不是开发人员!请指教。

我试过了

Redirect 301 "/old-folder/" "http://www.new.example/new-page.html"

Redirect 301 "/old-page.html" "http://www.new.example/new-page.html"

标签: .htaccessredirect

解决方案


old.example在.htaccess 文件顶部添加此规则

RewriteEngine On
RewriteBase /

RewriteRule ^ecards/birthday-ecards/all$ https://www.new.example/static-ecards/company-birthday-ecards.html [R=301,L]

推荐阅读