Rewrite https except subdomain?
3 posts
• Page 1 of 1
Rewrite https except subdomain?
Hi!
I have these rules:
#Redirect non-HTTPS to HTTPS
RewriteCond %{HTTP:Host} (.*)
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (.*)
RewriteRule .? https://%1%2 [R,L]
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
I want these things to work.
http://www.domain.com -> https://www .domain.com
http://domain.com -> https://www.domain.com
But this NOT to redirect to https:
http://test.domain.com
This subdomain I want to remain "as is".
Is there a way to rewrite code for this to work? I tried to modify the code above but never got it to work :/
Now it redirects all the 2 examples correct, but not the fourth.
Is there a way to "exclude" "test.domain.com" from all theses redirects?
Best regards
Fredrik
I have these rules:
#Redirect non-HTTPS to HTTPS
RewriteCond %{HTTP:Host} (.*)
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (.*)
RewriteRule .? https://%1%2 [R,L]
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
I want these things to work.
http://www.domain.com -> https://www .domain.com
http://domain.com -> https://www.domain.com
But this NOT to redirect to https:
http://test.domain.com
This subdomain I want to remain "as is".
Is there a way to rewrite code for this to work? I tried to modify the code above but never got it to work :/
Now it redirects all the 2 examples correct, but not the fourth.
Is there a way to "exclude" "test.domain.com" from all theses redirects?
Best regards
Fredrik
Re: Rewrite https except subdomain?
Hello Fredrik,
Please try using the following code:
#Redirect non-HTTPS to HTTPS
RewriteCond %{HTTP:Host} ^(?!test\.domain\.com)(.*)
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (.*)
RewriteRule .? https://%1%2 [R,L]
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!(?:www\.|test\.domain\.com))(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
Please try using the following code:
#Redirect non-HTTPS to HTTPS
RewriteCond %{HTTP:Host} ^(?!test\.domain\.com)(.*)
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (.*)
RewriteRule .? https://%1%2 [R,L]
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!(?:www\.|test\.domain\.com))(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 38 guests