我想在 url (1-9, a-z, A-z, -, _, %) 中允许
我在 htaccess 中有以下代码
RewriteRule ^shop/search/([a-zA-Z0-9_-]+)/?$ shop.php?search=$1 [QSA,NC]
问题:在 url 中传递空格时 示例
domain.com/shop/search/my%20keyword
它不工作
基本上我想通过 htaccess 在 url 中允许 %
怎么做?
最佳答案
... it is matched against the (%-decoded) URL-path of the request ...
source , 强调我的。
mod_rewrite 永远不会看到 %,它将 %20
解码为一个空格。如果您想在 URL 中接受 %20
,则向字符类添加空格。
关于php - 如何通过 htaccess 在 url 中允许 1-9 a-z A-Z - _ %?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38966322/