【问题标题】:Multiple domains on one host https and http一台主机上的多个域 https 和 http
【发布时间】:2019-07-31 06:43:24
【问题描述】:

我在一台主机上有多个域,我的 .htaccess 看起来像这样

RewriteEngine On
RewriteCond %{HTTP_HOST} web1.com$ [NC]
RewriteCond %{REQUEST_URI} !^/web_1/public/.*$
RewriteRule ^(.*)$ /web_1/public/$1 [L]

RewriteCond %{HTTP_HOST}  web2.com$ [NC]
RewriteCond %{REQUEST_URI} !^/web_2/public/.*$
RewriteRule ^(.*)$  /web_2/public/$1 [L]

到目前为止它仍然有效。现在我只希望 web1.com 而不是 web2.com 重定向到 https。我该如何更改设置? (到目前为止,我也很感谢有关如何更改我的“实现”的提示,我是 .htaccess 的新手并愿意了解更多相关信息)

【问题讨论】:

    标签: apache .htaccess https


    【解决方案1】:

    试试这个:

    RewriteCond %{HTTPS} !=on 
    RewriteCond %{HTTP_HOST}  web2.com$ [NC]
    RewriteRule ^(.*)$  https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    因此,您的规则将如下所示:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} web1.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/web_1/public/.*$
    RewriteRule ^(.*)$ /web_1/public/$1 [L]
    
    RewriteCond %{HTTPS} !=on 
    RewriteCond %{HTTP_HOST}  web2.com$ [NC]
    RewriteRule ^(.*)$  https://%{HTTP_HOST}/$1 [L,R=301]
    
    RewriteCond %{HTTP_HOST}  web2.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/web_2/public/.*$
    RewriteRule ^(.*)$  /web_2/public/$1 [L]
    

    【讨论】:

      猜你喜欢
      • 2013-07-13
      • 1970-01-01
      • 1970-01-01
      • 2012-12-02
      • 1970-01-01
      • 2022-08-21
      • 2017-11-03
      • 1970-01-01
      • 2015-07-18
      相关资源
      最近更新 更多