【问题标题】:Magento multistore redirect just one domain.com including path to httpsMagento 多存储仅重定向一个 domain.com,包括到 https 的路径
【发布时间】:2016-02-11 14:30:36
【问题描述】:

我在具有多个域的 magento 上设置了多存储。 但我只希望一个特定的商店/域拥有 https,并将该域的所有非 https url 重定向到 https。包括整个路径。

例如此列表中指向https://www 的所有网址。

来源网址: http://webwinkel.nl/willekeurige-categorienaam 万维网。 webwinkel.nl/willekeurige-categorienaam http://www.webwinkel.nl/willekeurige-categorienaam https://webwinkel.nl/willekeurige-categorienaam

目标网址: https://www.webwinkel.nl/willekeurige-categorienaam

我将它用于单个商店,在这种情况下它可以完美运行。

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

但是对于多商店,这不起作用,因为它会将每个商店域重定向到 https,但我只希望 https 用于一个特定的商店。

编辑

@itoctopus:感谢您的回复!

这适用于 www.webwinkel.nl。 但不适用于同一 multistore 上的其他域。

例如,我有 www.webwinkel.nl、www.webwinkel2.nl 和 www.webwinkel3.nl。 使用您的代码,它们都会重定向到 www.webwinkel.nl。

这是我现在的全部 htaccess:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(.*)webwinkel.nl [NC] 
RewriteRule . - [E=MAGE_RUN_TYPE:website]
RewriteCond %{HTTP_HOST} ^(.*)webwinkel.nl [NC] 
RewriteRule . - [E=MAGE_RUN_CODE:webwinkel] 

RewriteCond %{HTTP_HOST} ^(.*)webwinkel2.nl [NC] 
RewriteRule . - [E=MAGE_RUN_TYPE:website]
RewriteCond %{HTTP_HOST} ^(.*)webwinkel2.nl [NC] 
RewriteRule . - [E=MAGE_RUN_CODE:webwinkel2] 

RewriteCond %{HTTP_HOST} ^(.*)webwinkel3.nl [NC] 
RewriteRule . - [E=MAGE_RUN_TYPE:website]
RewriteCond %{HTTP_HOST} ^(.*)webwinkel3.nl [NC] 
RewriteRule . - [E=MAGE_RUN_CODE:webwinkel3] 


# First condition - redirect non-www to www for all domains
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Second condition - redirect HTTP to HTTPS for a particular domain
RewriteCond %{HTTP_HOST} ^webwinkel\.nl$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.webwinkel.nl/$1 [R=301,L]

【问题讨论】:

    标签: .htaccess magento redirect https multistore


    【解决方案1】:

    将以下代码添加到您的.htaccess 文件中,以确保只有特定域被重定向到https://www。第一个条件是为所有其他域处理从非 www 到 www 的重定向。第二个条件是将您的域重定向到 https。

    RewriteEngine On
    # First condition - redirect non-www to www for all domains
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    
    # Second condition - redirect HTTP to HTTPS for a particular domain
    RewriteCond %{HTTP_HOST} ^webwinkel\.nl$ [OR]
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://www.webwinkel.nl/$1 [R=301,L]
    

    【讨论】:

    • 关于这个主题的任何消息,正在寻找同样的东西吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-20
    • 1970-01-01
    相关资源
    最近更新 更多