[英]How do I ALLOW apostrophe in htaccess RewriteRule regex?
I'm retrieving menus from database and some of them have an apostrophe - ' - in their names. 我正在从数据库中检索菜单,其中一些菜单的名称中带有撇号-'。 In a part of my code I have to compare the name from the database with the url, but it fails when the url has an apostrophe.
在我的代码的一部分中,我必须将数据库中的名称与URL进行比较,但是当URL带有撇号时,它将失败。
For example: 例如:
when I get the name from the db I get it as it is: foo's
当我从数据库中获得名称时,我照原样获取它:
foo's
but from the url, even if the url is web.com?menu=foo's
when I do this: 但是从URL,即使我执行此操作,即使URL是
web.com?menu=foo's
也是如此:
$menu = urldecode($_GET['menu']);
I get only foo
我只有
foo
this is my htaccess Rewrite 这是我的htaccess重写
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^explore/([0-9a-zA-Z\ ]+) renderpage.php?menu=$1 [L]
I've tried all the possible combination in my php, it's not that, it is this RewriteRule that doesn't allow apostrophe, I've also tried ([0-9a-zA-Z\\ ']+)
in my regex and ([0-9a-zA-Z\\ \\']+)
but to no avail. 我已经在php中尝试了所有可能的组合,不是,不是这个RewriteRule不允许撇号,我也在正则表达式中尝试了
([0-9a-zA-Z\\ ']+)
([0-9a-zA-Z\\ \\']+)
但无济于事。
I think the issue is in the position of apostrophe Try this: 我认为问题出在撇号的位置,请尝试以下操作:
([0-9a-zA-Z'\]+)
or 要么
([0-9a-zA-Z']+)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.