2016-11-21 141 views
0

我有几个网站作为子网域,其主域名为site1.com。我的主域名有*.site1.com的通配符ssl证书。我的子域可以参考为site2.site1.com,site3.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.htaccess规则子域在所有页面上强制使用https

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> 

回答

0

我发现了一个简单的插件,为我完成了这项工作。这是我的.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> 
+0

不幸的是,我不能接受你的答案,因为它没有工作。我尝试了一个没有插件的独立子域,它做了同样的事情。对不起,男人,我可以upvote你的答案,但我不能接受它 –

相关问题