Combined 301 Redirect www, https and subdomain

15 views Asked by At

I have the htaccess lines below to redirect requests without www and https to https://www.domainname.com.

RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.domainname.com/$1 [QSA,R=301,END]

Then, if there are no subdomain at the end of requested url, I redirect it to /subdomain with:

RewriteCond %{HTTP_HOST} !^m\.
RewriteRule ^$ subdomain [R=301,L]

Is there a way to combine these two rules?

0

There are 0 answers