The following rule in .htaccess

RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://www .%1/$1 [R=301,L] 

when accessing the url of the form 

redirect to

 http://www ./something 

those. RewriteCond works, but transmits nothing. Someone tell me - what is the mistake here?

Immediately get better - an option with

  RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] RewriteRule ^(.*)$$1 [R=301,L] 

and other similar options work, this is understandable.

    1 answer 1

    The problem is that when denying, you cannot use $ N or% N. The example above will work if you only use% {HTTP_HOST} directly in the RewriteRule:

      RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www .%{HTTP_HOST}/$1 [R=301,L] 

    This is the answer, actually. The question is closed )