views:

68

answers:

1

Hi, it's been a couple of hours now that I'm working on this and I can't seem to figure out what the correct regex is.

First of all, I'm working with IIS6 and ISAPI_Rewrite 3.0 and I'm testing my regex with the utlity that comes with it before using it on the web site.

The website has an web app located at www.foo.com/bar/ and I want to restrict the access to any subfolders and/or subfiles other than default.aspx.

Which means that www.foo/bar/default.aspx should work but not www.foo/bar/oof or www.foo/bar/oof/.../rab.txt

Here is what I've got in my httpd.ini file :

RewriteCond URL
RewriteRule /gs2/(\w|\.|\\|\/)+ /gs2/ [RP]

It works fini for eveything but the default.aspx. I know why but I just can't figure out the correct syntax.

Thanks

A: 

Maybe you want

RewriteRule /foo/bar/.*   /foo/bar/default.aspx [RPL]

This redirects everything after /foo/bar/ to /foo/bar/default.aspx, setting [RPL] means that this is the last rule that is applied so you don't end up in a loop.

Otto Allmendinger
The doc says that the R is always the last rule. Plus it doesn't work for me. Since my default file for IIS is default.aspx, couldn't I simply remove it in the format string? **Edit**: When I add the 'L' it stops working...
Frank
You answer inspired me ;) The whole idea of URL-Rewritting was to block access to certain file type on the server. I've did this for xml and swf file like this : RewriteRule /gs2/(.+)((\.xml)|(\.swf)) /gs2/ [R]
Frank