[英]How do I create an Apache mod_rewrite rule that works with urlencoded values?
I'm using the php function urlencode http://php.net/manual/en/function.urlencode.php to encode a GET parameter $_GET['test']
我正在使用php函数urlencode http://php.net/manual/en/function.urlencode.php编码GET参数
$_GET['test']
I want to use an apache rewrite rule to rewrite urls like website.com/%CE%A6
to website.com/index.php?test=%CE%A6
我想使用apache重写规则将
website.com/%CE%A6
URL重写为website.com/index.php?test=%CE%A6
RewriteRule ^([a-z0-9])/?$ /index.php?test=$1 [NC,L]
What is a regex that can be used in place of [a-z0-9]
to accept the range of valid characters returned by the urlencode
function? 什么是可以代替
[a-z0-9]
接受urlencode
函数返回的有效字符范围的正则表达式?
You can just capture anything until you get a /
with a RewriteCond
to prevent looping: 您可以捕获任何东西,直到获得带有
RewriteCond
的/
以防止循环为止:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?test=$1 [QSA,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.