我对为什么URL以斜杠结尾时返回错误参数感到有些困惑。
htaccess
RewriteRule ^account/dashboard/(.*)/(.*)$ ./account/index.php?page=dashboard&aid=$1&name=$2 [L,QSA]
当我执行 http://example.com/account/dashboard/65/blitzen12/
在页面中我可以使用$_GET['aid]
它返回65/blitzen12
并$_GET['name]
返回空
但是,当我blitzen12
在网址末尾删除斜杠时,它正确返回了65
and blitzen12
。
谁能向我解释我做错了什么?
您应该这样做:
RewriteRule ^account/dashboard/([^/]+)/([^/]+)/?$ ./account/index.php?page=dashboard&aid=$1&name=$2 [L,QSA]
这与贪婪的重复有关。基本上,点匹配任何字符,包括斜杠(/)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句