【问题标题】:force https for few domains ot of all using htaccess but all domains shared same files使用 htaccess 强制少数域使用 https,但所有域共享相同的文件
【发布时间】:2014-12-18 01:43:55
【问题描述】:

我已经设置了系统,因此所有不同的域都使用相同的文件,并根据分配给每个域的商店 ID 来分隔内容或产品。

现在我只想强制 2 个域对所有使用 httaccess 的页面使用 https。

比如说,我有 5 个域 abc.com、qwe.com、xyz.com、rty.com 和 uio.com

现在我希望 abc.com 和 xyz.com 强制使用 https,而不是其他域。

我将如何在 htaccess 文件中为此重写规则?

【问题讨论】:

    标签: php .htaccess url-rewriting


    【解决方案1】:

    试试:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www\.)?(abc|xyz)\.com$ [NC]
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R]
    

    在文档根目录的 htaccess 中。

    【讨论】:

      【解决方案2】:

      这应该适用于您的情况:

      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^abc\.com
      RewriteCond %{HTTP_HOST} ^xyz\.com
      RewriteRule ^(.*)$ https://www.%{HTTP_HOST}.com$1 [R=permanent,L]
      

      【讨论】:

        猜你喜欢
        • 2014-01-20
        • 2016-06-02
        • 1970-01-01
        • 2012-01-01
        • 1970-01-01
        • 2016-09-25
        • 1970-01-01
        • 1970-01-01
        • 2012-10-27
        相关资源
        最近更新 更多