【问题标题】:.htaccess rules for subdomain to force https on all pages子域的 .htaccess 规则在所有页面上强制使用 https
【发布时间】:2016-11-21 05:06:10
【问题描述】:

我有几个站点作为子域,主域名为 site1.com。我的主域有一个*.site1.com 的通配符 ssl 证书。我的子域可以引用为site2.site1.comsite3.site1.comsiteN.site1.com。我的主域正确使用证书并在所有页面上强制使用 https,我的子域仅在管理页面上使用 https,我使用的是 wordpress CMS,或者如果我将我的网站引用为 https://site2.site1.com,我可以强制使用证书, https://site3.site1.com etc。我想让我的子域以https://site2.com 运行。目前我的域名为http://site2.comhttp://site1.site2.com

PS:我无法访问 vhost 文件。这是我所有域的 .htaccess 代码:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# BEGIN WordPress

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

SetEnvIfNoCase User-Agent "^libwww-perl*"  block_bad_bots
Deny from env=block_bad_bots

</IfModule>

【问题讨论】:

    标签: wordpress .htaccess ssl mod-rewrite


    【解决方案1】:

    我找到了一个简单的插件来为我完成这项工作。这就是我的 .htaccess 文件现在对于我的子域的样子:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    
    
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    
    # BEGIN WordPress
    
    #RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    # END WordPress
    SetEnvIfNoCase User-Agent "^libwww-perl*"  block_bad_bots
    Deny from env=block_bad_bots
    </IfModule>
    

    【讨论】:

    • 很遗憾,我无法接受您的回答,因为它不起作用。我用没有插件的单独子域尝试了这个,它做了同样的事情。对不起,伙计,我可以投票赞成你的回答,但我不能接受
    猜你喜欢
    • 2013-01-22
    • 2014-01-20
    • 1970-01-01
    • 2012-01-01
    • 2013-11-12
    • 1970-01-01
    • 2021-03-22
    • 2012-08-12
    • 2017-10-08
    相关资源
    最近更新 更多