RewriteCond: unable to compile regex

I am using this .htaccess:

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

I get an error in the browser:

Internal Server Error

The server detected an internal error or an incorrect configuration and your request failed.

Contact the server administrator, webmaster@cyberotech.com and let them know when the error occurred, and anything else that could lead to the error.

Additional information about this error may be available if a server error occurs.

/var/log/apache2/error.log He speaks:

RewriteCond: cannot compile regular expression '*!^www*.kerala\\.local'
+3
source share
1 answer

Your regular expression is really wrong. (there are star-shaped stars)

Use this code instead:

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

All Articles