2016-04-21 35 views
1

我有一個名爲域:example.com和一個叫子域名:sub.example.comHTTPS子域不正確htaccess的重定向

我要強制爲example.com中的所有主域請求到https: //除了1個文件夾。例如:

http://www.example.com/ <-- Redirect all requests to https:// 
http://www.example.com/folder/ <-- Force to http:// not https:// 

我也想強制sub.example.com的所有子域請求到https://除了1個文件夾。例如:

http://sub.example.com <-- Redirect all requests to https:// 
http://www.example.com/folder/ <-- Force to http:// not https:// 

目前example.com是工作的罰款,並強制將https://開頭的主域和文件夾重定向沒有到https://但是文件夾沒有強制執行的http://如果有人選擇https://

如果我訪問http://sub.example.com它不強制執行https://,如果我手動訪問https://sub.example.com,它會在url中顯示。但是它顯示的網站實際上是從https://www.example.com

htaccess的文件我有example.com是:

<IfModule mod_rewrite.c> 

    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]   
    RewriteCond %{HTTP_HOST} !^sub.example.com$ [NC] 
    RewriteCond %{REQUEST_URI} !^/folder/ 
    RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,QSA,L] 

</IfModule> 

htaccess的文件我有sub.example.com是:

RewriteEngine on 
RewriteBase/
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} !^/folder/ 
RewriteCond %{HTTP_HOST} ^example\.com\.au$ [NC] 
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

回答

0

我發現了這個問題。它與htaccess文件無關。我發現我已經安裝到主域上​​的證書並且子域沒有匹配的證書。

Apache被重定向到ssl證書域而不是子域。我通過購買通配符ssl解決了這個問題,將其安裝到主域上​​,然後將其分別安裝到子域。

這解決了這個問題。