【问题标题】:.htaccess 3 different domains , 3 different 301.htaccess 3 个不同的域,3 个不同的 301
【发布时间】:2015-07-30 13:20:37
【问题描述】:

目前我正在使用 3 个不同的域运行 Magento。我想为这三个中的每一个设置一个 301 重写规则,所以“www”。当用户输入“domain.de”时被添加到他们中

例如:domain.de 被重写为 www.domain.de

目前我的代码如下:

Rewriteengine on
RewriteCond %{HTTP_HOST} !^www\.domain\.de$ [NC] 
RewriteRule ^(.*)$ http://www.domain.de/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC] 
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.example\.de$ [NC] 
RewriteRule ^(.*)$ http://www.example.de/$1 [L,R=301]

问题是代码导致了重定向循环,我不知道问题可能是什么。 如果有人能告诉我代码有什么问题,我会很高兴...

【问题讨论】:

    标签: apache .htaccess magento mod-rewrite redirect


    【解决方案1】:

    问题是RewriteCond %{HTTP_HOST} !^www\.domain\.de$ 是一个否定条件,并且也与其他 2 个域匹配。

    用这条规则替换你的 3 条规则:

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

    请记住在测试此规则之前清除浏览器缓存。

    【讨论】:

      猜你喜欢
      • 2019-02-11
      • 2015-12-28
      • 1970-01-01
      • 1970-01-01
      • 2021-05-15
      • 1970-01-01
      • 1970-01-01
      • 2012-03-12
      • 1970-01-01
      相关资源
      最近更新 更多