RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.new.domain.com [NC]
RewriteRule ^(.*)$ http://new.domain.com/$1 [L,R=301]
why when i enter http://www.new.domain.com is not redirected to http://new.domain.com?
The .htaccess file is in the right folder (it has more rewritecond’s and they work)
The regexp syntax in your RewriteCond is slightly broken: the correct way to test for strict equality with
www.new.domain.com(up to differences in case) is eitheror
That said, those errors should not stop your rewrite rule from working: you original RewriteCond will match
www.new.domain.comjust fine, it just matches some other strings too (likewwwXnewYdomainZcomFOOBAR). In fact, I have a very similar set of rules in my own.htaccessfile, and they work just fine:Most of the differences between your code and mine are purely cosmetic. The only potentially significant issue I can see if that you don’t have a
RewriteBasedirective; you should definitely add one, if only to avoid potential problems later. Still, as far as I can tell, not having one shouldn’t stop you from getting at least some redirect, even if it might not be to the URL you expect.