【问题标题】:Redirect 301 domain and some pages重定向301域和一些页面
【发布时间】:2021-04-10 19:18:37
【问题描述】:

我需要使用 htaccess 将我的 old-domain.com 重定向到 new-domain.com

新域名有不同的url

old-domain.com/aboutus.htmlnew-domain.com/us.html

old-domain.com/contact-us.htmlnew-domain.com/form.html

..... .....

所有其他页面 old-domain.com/xxxxxxxxxxx 重定向到主页 new-domain.com

谢谢

【问题讨论】:

  • 欢迎来到 SO,请在您的问题中添加您尝试过的 htaccess 规则文件,谢谢。

标签: apache .htaccess redirect mod-rewrite seo


【解决方案1】:

假设您使用的是 apache http 服务器,您需要在您的 http 服务器中启用重写模块,并且您需要实现这些重写规则:

RewriteEngine on
RewriteRule ^/?aboutus\.html$ /us.html [R=301,END]
RewriteRule ^/?contact-us\.html$ /form.html [R=301,END]
RewriteRule ^ / [R=301,END]

这些规则可以放在你的 http 服务器的主机配置中。如果您无权访问,则必须使用分布式配置文件(“.htaccess”),该文件应放置在 http 主机的 DOCUMENT_ROOT 文件夹中。请记住,在这种情况下您需要启用对此类文件的解释,请查看 apache http 服务器文档中的 AllowOverride 指令。

【讨论】:

    猜你喜欢
    • 2014-06-24
    • 1970-01-01
    • 1970-01-01
    • 2012-04-13
    • 2013-12-14
    • 1970-01-01
    • 1970-01-01
    • 2014-09-23
    • 2020-03-08
    相关资源
    最近更新 更多