I’m trying to make a general rewrite rule to redirect all domain.com requests to http://www.domain.com.
RewriteCond %{HTTP_HOST} ^([0-9a-z-]+)\.([0-9a-z-]+])$ [NC]
RewriteRule ^(.*)$ http://www.{HTTP_HOST}/$1 [R=301,L]
The problem is that this rewrite rule doesn’t match anything. How can I change it? Thanks
I guess the problem is that there’s an additional
]in yourRewriteCond’s pattern and that there is a%missing when referencing HTTP_HOST inRewriteRule’s substitution. So try this:And to cover Cags’ concerns a litte bit, you can also try this rule: