2016-11-21 66 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你的答案,但我不能接受它 –

相關問題