سؤال

I am using this .htaccess :

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

I am getting the error in browser:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@cyberotech.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

The /var/log/apache2/error.log says:

RewriteCond: cannot compile regular expression '*!^www*.kerala\\.local'
هل كانت مفيدة؟

المحلول

Your regex is indeed wrong. (there are stray asterisks)

Use this code instead:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301] 
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top