check if directory exists

Topics: Developer Forum, User Forum
Jul 2, 2009 at 5:04 PM

I'm wondering if there is way to test if a directory exists before performing a rewrite or redirect. Currently, I am using a blanket rule that catches all incoming requests and performs a rewrite:

RedirectRule        (^[^.]+[^/]$)    $1/ [I,R]
RewriteRule        ^/(.*)\.(.*)    -    [L]
RewriteRule        ^/(.*)$        /test/rewrite.aspx/$1

Although this may change in the future, it is unlikely. Does anyone know a way to add a Rule into the mix that will check if an incoming request correlates to an actual directory before performing the rewrites above? (current Redirect to add / will always happen first)

Coordinator
Jul 5, 2009 at 11:03 PM

Yes, check the readme for the -d condition (RewriteCond).

See example 16 in the latest readme-1.2.txt file