.htaccess rewrite rules
Posted
by psynnott
on Server Fault
See other posts from Server Fault
or by psynnott
Published on 2010-03-31T16:30:44Z
Indexed on
2010/03/31
16:33 UTC
Read the original article
Hit count: 658
The below code adds www. to any url that does not start with it:
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://www.%2%{REQUEST_URI} [L,R=301]
However, I want it to do this only when the url is of the format:
something.com
If the url is like:
something.something.com
I do not want the rule adding www.
How do I change this?
© Server Fault or respective owner