This is a relatively standard question, but I cannot seem to get it to work on URLs that already have a rewrite going on.
For example, I have this URL:
http://example.com/this-is-rewritten/
https://example.com/this-is-rewritten/
should go to:
http://www.example.com/this-is-rewritten/
https://www.example.com/this-is-rewritten/
and I want to make sure that it is always WWW in front, if it is not a subdomain URL. So, if we had:
http://subdomain.example.com/this-is-rewritten/
That should NOT go to WWW. This is what I have so far, but it will send you to the under lying URL with querystring, not to the same "/this-is-rewritten/" url. Also, the http or https should be preserved.
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?:www.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://%2%3 [R=301,L]
Try:
or if you only have a specific host: