使用 ISAPI-Rewrite 排除目录
我试图用 ISAPI-Rewrite 排除一个目录(注意:这是 mod-rewrite 的 windows/iis 端口)。
我想要排除的目录是“api”,当它位于站点的根目录时。
这是我的规则:
RewriteRule ^(/api/)(.+)$ $1$2 [NC, L]
请求看起来像这样: /api/v2/users?usernames=scottw
不幸的是,查询字符串值始终被排除,并且 url 被重写为 /api/v2/users。
我的攻击假设是 (.+) 会捕获其他所有内容。
有什么建议么? 或者排除目录的更好方法?
谢谢
更新:我还简化了规则,但这也没有改变任何内容:
RewriteRule ^(/api/.+)$ $1
I am trying to exclude a directory with ISAPI-Rewrite (note: this is a windows/iis port of mod-rewrite).
The directory I want to exclude is "api" when it is at the root of the site.
Here is my rule:
RewriteRule ^(/api/)(.+)$ $1$2 [NC, L]
A request would look something like this:
/api/v2/users?usernames=scottw
Unfortunately, the querstring value is always being excluded and the url is being rewrittten as /api/v2/users.
I am attacking under the assumption that (.+) would capture everything else.
Any suggestions? Or a better way to exclude a directory?
Thanks
Update: I have also simplified the rule, but that has not changed anything either:
RewriteRule ^(/api/.+)$ $1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
结果这里发生了两件事:
最终看来有效的规则是:
Turns out there are two things going on here:
The rule which finally appears to be working is:
我有时发现“.+”工作得很奇怪,您可能会尝试切换到“..*”,我并不是说它会起作用,但可能值得一试。
I've seen sometimes '.+' works oddly, you might try to switch to '..*' I'm not saying it will work, but it might be worth a try.