繁体   English   中英

如何创建适用于urlencoded值的Apache mod_rewrite规则?

[英]How do I create an Apache mod_rewrite rule that works with urlencoded values?

我正在使用php函数urlencode http://php.net/manual/en/function.urlencode.php编码GET参数$_GET['test']

我想使用apache重写规则将website.com/%CE%A6 URL重写为website.com/index.php?test=%CE%A6

RewriteRule ^([a-z0-9])/?$ /index.php?test=$1 [NC,L]

什么是可以代替[a-z0-9]接受urlencode函数返回的有效字符范围的正则表达式?

您可以捕获任何东西,直到获得带有RewriteCond/以防止循环为止:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?test=$1 [QSA,L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM