1

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

例如,此列表中的所有 url 都指向https://www

来源网址:http://webwinkel.nl/willekeurige-categorienaam www。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。但不适用于同一多存储上的其他域。

例如,我有 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]
4

1 回答 1

0

将以下代码添加到您的.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]
于 2015-11-10T22:54:32.193 回答