I'm using UrlR开发者_开发百科ewriter.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.
I got it working with:
<rewrite url="~/(.*)/Styles/(.+)?" to="~/Styles/$2" />
<rewrite url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js)(\?.+)?)$" to="$1" processing="stop" />
精彩评论