2017-09-05 133 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]