301重定向我的网站中的任何url



我需要创建从myOldSite.com到myNewSite.com 的301重定向

我在myOldSite.com 的htaccess中有这个代码

#Redirect 301 / https://myNewSite.com/myPage/

这可以很好地重定向myOldSite.com,但不能激发myOldSite.com/services.html:的正确重定向

myOldSite.com被正确重定向到myNewSite.com/myPage

但是

myOldSite.com/services被重定向到myNewSite.com/myPage/services.html这是错误的

正如您所看到的,services被附加到末尾。这不是我需要的。我需要:

myOldSite.com/services重定向到myNewSite.com/myPage

任何以myOldSite.com/ANYTHING_HERE开头的url都应重定向到myNewSite.com/myPage

使用RedirectMatch

RedirectMatch 301 / https://myNewSite.com/myPage

这不会将旧的URL子路径附加到目标URL。

最新更新