windylad
asked on
rewrite for subdomain to SSL?
Hello,
I’m looking to enforce SSL access to a subdomain using a rewrite rule. When users visit http://subdomain.domain.com/* the rewrite rule should point the user at httpS://subdomain.domain.com/*
I’ve looked at the following rule, which works across the whole site, but I’m not familiar with the syntax to modify it for a subdomain only.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Any help appreciated,
/wl
I’m looking to enforce SSL access to a subdomain using a rewrite rule. When users visit http://subdomain.domain.com/* the rewrite rule should point the user at httpS://subdomain.domain.com/*
I’ve looked at the following rule, which works across the whole site, but I’m not familiar with the syntax to modify it for a subdomain only.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Any help appreciated,
/wl
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi ravenpl,
Thanks for the answer. I've tried both of the following and both work; whats the difference in the last line?
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain.domain. com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain.domain. com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
Thanks,
/wl
Thanks for the answer. I've tried both of the following and both work; whats the difference in the last line?
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain.domain.
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain.domain.
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
Thanks,
/wl
L - means don't try next rewriteRules on this result
R - means don't rewrite, but redirect(301 response code is sent to client) - I guess it's default if protocols/ports do not match...
R - means don't rewrite, but redirect(301 response code is sent to client) - I guess it's default if protocols/ports do not match...
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain.domain.
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}