【发布时间】:2019-08-20 13:27:42
【问题描述】:
我已经搜索了一段时间,并且看到了一些类似的问题,但没有找到我想要的。
我有两个域,比如说 domain1.com 和 domain2.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