我正在使用这个 .htaccess :
RewriteEngine On
RewriteCond %{HTTP_HOST} *!^www*.kerala\.local [NC]
RewriteRule (.*) http://www.kerala.local/$1 [L,R=301]
我在浏览器中遇到错误:
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.
/var/log/apache2/error.log
说:
RewriteCond: cannot compile regular expression '*!^www*.kerala\\.local'
最佳答案
您的正则表达式确实是错误的。 (有杂散的星号)
改用这段代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
关于regex - 重写条件 : cannot compile regular expression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21906067/