RE: .htaccess - how to force "www." in a generic way?
I asked this question before, and got this answer:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
It works, but now I am seeing 301 Moved Permanently
in the response headers. I want to eliminate the 301s. Is the problem the 2nd rewrite condition? Should it be something like "does not start with 'www.' followed by the host name"?
By the way, I want this solution to work for any server (meaning, I don't want to hard code my domain name).
Suggestions?
UPDATE:
I just realized that the above is not working correctly. If I have the following:
http://images.domain.com
I don't want that to change to:
http://www.images.domain.com
I don't want this affecting sub-domains. I only want it to affect missing www
.