本文介绍了重写规则的preserves GET参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是错的这个重写规则?
What is wrong with this rewrite rule?
RewriteRule ^api/(.+)$ api/index.php?url=$1 [L]
我只是希望的index.php?URL =被API之后/之前的get参数的其余部分补充说。
I simply want "index.php?url=" to be added after api/ and before the rest of the get parameters.
api/image/upload&arg1=1&text=lorem+ipsum
到
api/index.php?url=image/upload&arg1=1&text=lorem+ipsum
什么是错的(+)API后得到的一切/?
What is wrong with (.+) to get everything after api/?
推荐答案
在重写规则的正则表达式只针对URL,而不是查询参数的路径部分运行。幸运的是 [QSA]
标记以preserve现有的查询参数。
The regex on the RewriteRule is only run against the path part of the URL, not the query parameters. Fortunately there is the [QSA]
flag to preserve existing query parameters.
这篇关于重写规则的preserves GET参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!