[英]RewriteRule: bad flag delimiters
Here is my .htaccess
file: 这是我的
.htaccess
文件:
ErrorDocument 404 /index.php?cmd=notfound
# Maintenance
RewriteCond %{REMOTE_ADDR} !^(Redacted)
RewriteRule ^ maintenance.php [L]
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\w+)(?:/(\w+))?(?:/(\w+))?(?:/(\w+))?(?:/(\w+))?(?:/(\w+))?/?$ route.php?1=$1&2=$2&3=$3&4=$4&5=$5&6=$6 [L]
It works, no errors, however there is a problem: the last RewriteRule doesn't allow spaces in the arguments. 它可以正常工作,没有错误,但是存在一个问题:最后一个RewriteRule不允许在参数中使用空格。
I was told by somebody to replace \\w+
with [\\w ]+
, but when I do that I get an error: 有人告诉我用
[\\w ]+
替换\\w+
[\\w ]+
,但是当我这样做时,我得到一个错误:
RewriteRule: bad flag delimiters
Zapk, it sounds like HamZa already told you the solution: yes, \\s
will match spaces (as in most regex flavors). Zapk,听起来好像HamZa已经告诉您了解决方案:是的,
\\s
将匹配空格(就像大多数正则表达式一样)。
For completion, here is a fact that is too-little known: Apache uses PCRE for regex matching. 对于完成,这是一个鲜为人知的事实:Apache使用PCRE进行正则表达式匹配。 This is great news for web admins as PCRE is one of the most full-featured engines around.
这对于Web管理员来说是个好消息,因为PCRE是周围功能最强大的引擎之一。 So you can do a lot of things beyond the usual ugly examples of Apache redirects floating around the interweb.
因此,除了在Internet上浮动的Apache重定向的常见丑陋示例之外,您还可以做很多事情。
As a start, I must say that it's a pleasure to the eyes to see that you are using an unescaped forward slash in your regex, while many examples around the web make a big soup of unnecessary \\/\\/
It's also a treat to see that you are using non-capturing groups. 首先,我必须说,很高兴看到您在正则表达式中使用了未转义的正斜杠,而网络上的许多示例都给不必要的
\\/\\/
增添了很多汤水,这也是一种享受您正在使用非捕获组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.