Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我在htaccess重写规则中使用什么regexp来匹配URI中的%s?_Regex_.htaccess_Mod Rewrite - Fatal编程技术网

我在htaccess重写规则中使用什么regexp来匹配URI中的%s?

我在htaccess重写规则中使用什么regexp来匹配URI中的%s?,regex,.htaccess,mod-rewrite,Regex,.htaccess,Mod Rewrite,当用户在浏览器中键入此项时: 我希望他们在这里结束: 我当前的htaccess重写规则如下所示: RewriteRule ^collection/([a-z0-9\-\%]+)$ collection/index.html?pname=$1 [NC,L] 。。。但这失败了。当我这样做时: RewriteRule ^collection/(.+)$ collection/index.html?pname=$1 [NC,L] 。。。它也失败了。我知道%是一个受保护的regexp字符,但是在它前

当用户在浏览器中键入此项时: 我希望他们在这里结束:

我当前的htaccess重写规则如下所示:

RewriteRule ^collection/([a-z0-9\-\%]+)$ collection/index.html?pname=$1 [NC,L]
。。。但这失败了。当我这样做时:

RewriteRule ^collection/(.+)$ collection/index.html?pname=$1 [NC,L]
。。。它也失败了。我知道%是一个受保护的regexp字符,但是在它前面加上文字\应该可以,对吗?有什么建议吗?

%不是正则表达式元字符,问题是它用于对URL中的字符进行编码,因此您不能在URL中仅使用文本%,因为它意味着开始一个识别特殊字符的序列:

如果你想在一个URL中有一个真实的%,你必须将其编码为%25。

是一个错误地在电子邮件中发送给一个大群组的链接。该组正在单击它,链接失败。我正试图写一些东西来修正这个错误。有没有办法编写一个重写规则来匹配“something0%d”并修复它,使其最终位于正确的位置?没有,链接在到达服务器之前已断开