bli*_*n12 0 php apache .htaccess mod-rewrite
当url以斜杠结尾时,我对它返回错误参数的原因感到有点困惑.
htaccess的
RewriteRule ^account/dashboard/(.*)/(.*)$ ./account/index.php?page=dashboard&aid=$1&name=$2 [L,QSA]
Run Code Online (Sandbox Code Playgroud)
当我执行 http://example.com/account/dashboard/65/blitzen12/
并在页面中我可以使用$_GET['aid]它返回65/blitzen12并$_GET['name]返回空
但是当我blitzen12在url 的末尾删除斜杠时,它会正确返回,这是65和blitzen12.
谁能向我解释我做错了什么?
你应该这样做:
RewriteRule ^account/dashboard/([^/]+)/([^/]+)/?$ ./account/index.php?page=dashboard&aid=$1&name=$2 [L,QSA]
Run Code Online (Sandbox Code Playgroud)
它与贪婪的重复有关.基本上,点匹配任何字符,包括斜杠(/)
| 归档时间: |
|
| 查看次数: |
276 次 |
| 最近记录: |