[HCoop-Help] Domtool mod_rewrite: rewriteCond for existent / non-existent files

Adam Chlipala adamc at hcoop.net
Sun Apr 12 13:29:29 EDT 2009


You can run "domtool-admin describe YOURDOMAIN" to see the Apache 
configuration that is being generated.  If you can tell me what 
configuration you would like to generate but can't (with the literal 
configuration code, not a request for some behavior), I can add 
something new.  I'm not familiar with mod_rewrite details and can't help 
in any other way.

Michal wrote:
> 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?
>   




More information about the HCoop-Help mailing list