帮助 REST API 进行 mod-rewrite(有点像 twitter API)
我有一个问题要问 mod-rewrite 专家:p
我已经构建了一个 REST api,我正在为一些不错的 URL 进行 .htaccess mod-rewriting。
我想要这个... api.site.com/[contacts].[json]?location=[new york,NY]
要映射到此... site.com/includes/api/v2/api_receiver.php?action=[contacts]&format=[json]&location=[new york,NY]
参数位于方括号中。
它基本上就像 twitter API: http://apiwiki.twitter .com/Twitter-REST-API-Method%3A-POST-lists
非常感谢任何帮助:)
I've got a question for the mod-rewrite gurus out there :p
I've got a REST api built, I'm just working on the .htaccess mod-rewriting for some nice URLs.
I would like this...
api.site.com/[contacts].[json]?location=[new york,NY]
To map to this...
site.com/includes/api/v2/api_receiver.php?action=[contacts]&format=[json]&location=[new york,NY]
The parameters are in square brackets.
It's basically like the twitter API: http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-POST-lists
Any help is much appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可以做到:
QSA = Query-String-Appened,它将负责将 location=... 部分附加到末尾。
NC = nocase,这将使 az 也匹配 AZ。
This should do it:
QSA = Query-String-Appened, which will take care of appending the location=... part to the end.
NC = nocase, which will lets a-z match A-Z too.
至于域名重定向,你需要
(谢谢你让我学习 mod_rewrite,顺便说一句)
As for the domain redirection, you'll need
(Thanks for making me learn mod_rewrite, by the way)