【问题标题】:Setting up a 301 redirect from different domains设置来自不同域的 301 重定向
【发布时间】:2014-09-24 11:29:55
【问题描述】:

我目前有以下设置:

  • www.domainx.com - 主要网站
  • www.domainx.de(外国域) - 此域重定向到 www.domainx.com/de

我需要将 www.domainx.com/product1 重定向到 www.domainx.com/product.php?id=123 - 这是我通过 .htaccess 完成的

棘手的部分是试图让 www.domainx.de/product1 重定向到 www.domainx.com/de/product.php?id=123

有什么想法吗?

【问题讨论】:

  • This i've done via .htaccess 向我们展示您当前的 .htaccess
  • 当前.htaccess文件如下: DirectoryIndex index.php Redirect 301 /productx domainx.com/products/detail.php?id=96 RewriteEngine On RewriteCond %{HTTP_HOST} ^domainx.com RewriteRule (.*) domainx.com/$1 [R=301 ,L]

标签: apache .htaccess mod-rewrite redirect http-status-code-301


【解决方案1】:

你可以在你的 root .htaccess 中拥有这样的规则:

DirectoryIndex index.php
RewriteEngine On

RewriteCond %{HTTP_HOST} ^domainx\.com$ [NC]
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L,NE]

RewriteCond %{HTTP_HOST} ^www\.domainx\.com$ [NC]
RewriteRule ^productx/?$ /products/detail.php?id=96 [L,NC,R=302]

RewriteCond %{HTTP_HOST} ^www\.domainx\.de$ [NC]
RewriteRule ^product1/?$ http://www.domainx.com/de/product.php?id=123 [L,NC,R=302]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    • 2021-06-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-08
    • 1970-01-01
    相关资源
    最近更新 更多