2017-09-05 84 views
0

我用下面的規則,但具有與子域的問題作爲http://sub.example.com被重定向到https://sub.example.com/sub,而不是https://sub.example.com非www會以https WWW子域發出

RewriteEngine On 
# Redirect non-www to (ssl) www 
RewriteCond %{HTTP_HOST} ^example\.com [NC] 
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] 
# Redirect non-SSL to SSL 
RewriteCond %{HTTPS} !on 
RewriteCond %{SERVER_PORT} !^443$ 
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] 

可能是什麼問題?

+0

有什麼期望的結果? – Bananaapple

+0

編輯我的問題,包括所需的結果/重定向 – Webbs

回答

0

我能夠解決這個問題:

RewriteEngine On 
# Redirect non-www to (ssl) www 
RewriteCond %{HTTP_HOST} ^example\.com$ [NC] 
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

# Redirect non-SSL to SSL 
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
相關問題