Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个重写规则,但我想修改它,以便只有 7 个字符串符合该标准。我无法弄清楚如何做到这一点,我什至不确定它是否可能。
RewriteRule ^([a-z0-9]+)/?$ rewrite.php?id=$1 [NC,L]
使用{7}代替+:
{7}
+
RewriteRule ^([a-z0-9]{7})/?$ rewrite.php?id=$1 [NC,L]
这将只匹配 7 个字母和数字,
RewriteRule ^([a-z0-9]{7,})/?$ rewrite.php?id=$1 [NC,L]
这将匹配 7 个或更多字母和数字。
RewriteRule ^([a-z0-9]{1,7})/?$ rewrite.php?id=$1 [NC,L]
这将匹配一个或多个和七个或更少的字母和数字。