I'm trying to write rewrite rules that depends on whether a file
exists. Specifically to only rewrite an URL if a file does *not*
exist. A simple example is the following. I would think the following
should only show the image '/images/home.png' when browsing to the
*non-existent* directory:

    rewriteCond "%{REQUEST_FILENAME}" "!-f" [];
    rewriteCond "%{REQUEST_FILENAME}" "!-d" [];
    rewriteRule "^/nonexistant/$" "/images/home.png" [last];

    rewriteCond "%{REQUEST_FILENAME}" "!-f" [];
    rewriteCond "%{REQUEST_FILENAME}" "!-d" [];
    rewriteRule "^/existant/$" "/images/home.png" [last];

However if shows the image when going to both directories.

I notice that the [] is required for a rewriteCond (if I omit it then
I get an error relating to mod_rewrite_cond_flag). However, I can't
find mention of a flag in the Apache docs
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteCond ,
and the Domtool reference doesn't explain either
http://hcoop.net/domtool/mod_rewrite.html#T_mod_rewrite_cond_flag .
Could it be something to do with that: am I missing some flags?

_______________________________________________
HCoop-Help mailing list
[email protected]
https://lists.hcoop.net/listinfo/hcoop-help

Reply via email to