【问题标题】:Redirection domain1.com to domain2.com/page [duplicate]将 domain1.com 重定向到 domain2.com/page [重复]
【发布时间】:2019-08-20 13:27:42
【问题描述】:

我已经搜索了一段时间,并且看到了一些类似的问题,但没有找到我想要的。

我有两个域,比如说 domain1.comdomain2.com。我要将内容从 domain1.com 迁移到文件夹 domain2.com/page。除此之外,所有蛞蝓都将保持不变。所以,我希望 domain1.com 重定向到 domain2.com/page 以及像 domain1.com/whatever 这样的任何路径重定向到 domain2.com/page/whatever 等等。这是需要的代码还是其他什么?

RewriteEngine On

# First condition, requested resource is not an existing file in domain1.com (this condition can be removed if needed)
RewriteCond %{REQUEST_FILENAME} !-f

# Second condition, requested resource is not an existing directory file in domain1.com (this condition can be removed if needed)
RewriteCond %{REQUEST_FILENAME} !-d

# Third condition, slug must exist
RewriteCond %{REQUEST_URI} !^/?$

# Do the redirection
RewriteRule ^(.*)$ http://domain2.com/$1 [R=301,QSA,L]

【问题讨论】:

    标签: .htaccess seo url-redirection data-migration


    【解决方案1】:

    只需这样做:

    Redirect HTTP://domain1.com HTTP://domain2.com/pages
    

    不要忘记空格。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-21
      • 2020-07-23
      • 2019-03-05
      相关资源
      最近更新 更多