UrlRewriter.Net - 防止子目录规则
我正在使用 UrlRewriter.net,在 ScottGu 的博客。我已经围绕这个建立了一个网站,现在我遇到了子目录的问题。问题是,我想排除一个目录及其中的所有子目录/文件进行重写。我的规则是:
<rewrite url="~/(.*)/Uploads/Images/(.+)?" to="~/Uploads/Images/$2" processing="stop" />
<rewrite url="~/(.*)/Uploads/(.+)/(.+)?" to="~/Uploads/$2/$3" processing="stop" />
<rewrite url="~/(.*)/Uploads/(.+)?" to="~/Uploads/$2" />
问题是,虽然我可以访问上传目录(/Uploads/myfile.ext)中的文件并查看直接子目录(/Uploads/mySubdirectory/)的目录列表,但 /Uploads/mySubdirectory/ 中的任何内容,例如:/Uploads/mySubdirectory/myfile.ext 返回 404,因为 UrlRewriter 弄乱了 Url。我以不同的顺序尝试了这些规则,但没有成功。
以前有人用过这个吗?必须有一种方法让它发挥作用。
I'm using UrlRewriter.net, mentioned on ScottGu's Blog. I've built a site around this and now I'm having problems with subdirectories. The problem is, I want to exclude a directory and all subdirectories/files within it from rewriting. The rules I have are:
<rewrite url="~/(.*)/Uploads/Images/(.+)?" to="~/Uploads/Images/$2" processing="stop" />
<rewrite url="~/(.*)/Uploads/(.+)/(.+)?" to="~/Uploads/$2/$3" processing="stop" />
<rewrite url="~/(.*)/Uploads/(.+)?" to="~/Uploads/$2" />
The problem is, although I can access files in the uploads directory (/Uploads/myfile.ext) and see the directory lists for direct subdirectories (/Uploads/mySubdirectory/), anything in /Uploads/mySubdirectory/, eg: /Uploads/mySubdirectory/myfile.ext returns a 404, because the UrlRewriter is messing with the Urls. I've tried these rules in different orders to no avail.
Has anyone used this before? There must be a way to get it to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我让它与:
I got it working with: