RewriteRule:无法编译正则表达式 - apache 2.4.9

Anu*_*dha 2 regex apache .htaccess mod-rewrite

我在 Apache 错误日志中收到此错误,并且我的网站无法在 Apache 2.4.9 中打开

RewriteRule: cannot compile regular expression '^/?([a-zA-Z0-9_+-\\s+]+)$'
Run Code Online (Sandbox Code Playgroud)

但我能够在早期版本的apache中打开该网站,请帮忙apache 2.4.9有什么问题吗?

RewriteRule ^/?([a-zA-Z0-9_+-\s+]+)$ ?x=$1 [QSA,L]
Run Code Online (Sandbox Code Playgroud)

anu*_*ava 5

将您的规则更改为:

RewriteRule ^/?([\w+\s-]+)$ ?x=$1 [QSA,L]
Run Code Online (Sandbox Code Playgroud)

连字符需要位于字符类的开头或结尾以避免转义。