我有一个带有 multistore 的 prestashop 安装,所以我有 2 个域到相同的安装(不同的主题),我已经安装了一个 SSL 证书以按照 prestashop 1.5 的建议在主页和表单页面中运行。
例如:
我的商店 1 的 url 商店是 www.mystore1.com 我的商店 2 的 url 商店是 mystore2.com
现在证书运行良好,如果我浏览到 https://www.mystore1.com,我可以看到锁并且所有负载都正常,但问题是当我浏览到 www.mystore1.com 或 mystore1.com 时没有重定向到 https。我打开了 mod_rewrite 并重新生成了 htaccess 几次。
这是我为 multistore 工作的 htaccess,我想修改它:
<IFMODULE mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mystore1.com$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
RewriteCond %{HTTP_HOST} ^mystore2.es$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
现在我只想为支持的页面(主页和表单)将 http 到 https 添加到 mydomain1。请帮我把 www.mystore1.com 和 mystore1.com 重定向到 https://www.mystore1.com .
我试过:
RewriteCond %{HTTP_HOST} ^mydomain1\.com$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.mydomain1.com/$1 [R=301,L]
但仅适用于主页,非 https 页面将停止工作,它们应该可以毫无问题地加载为 http。
非常感谢!!
最佳答案
拥有 http 和 https 版本将导致您使用重复版本并可能受到 Google 的处罚。 您真的应该通过 .htaccess 或 PHP 重定向在任何地方强制使用 Https。
关于.htaccess - Http 到 Https 但不是整个站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47596800/