I'm using the php function urlencode http://php.net/manual/en/function.urlencode.php to encode a GET parameter $_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
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?
You can just capture anything until you get a /
with a RewriteCond
to prevent looping:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?test=$1 [QSA,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.