httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Andersson" <rob...@profundis.nu>
Subject Re: [users@httpd] Please help me with this error document directive
Date Wed, 10 Dec 2003 06:28:48 GMT
Jon Block wrote:
> Here are some URL's that should *not* hit my ErrorDocument directive....
>
> http://www.bbtp.com/news/2003/02/06/ArtsAndEntertainment
> http://www.bbtp.com/news/2003/02/06/ding/
> ...snip...
>
> Here are the url's that *should* hit my error handler
>
> http://www.bbtp.com/news/2003/02/06/yay/iofdios.shtml
> http://www.bbtp.com/news/2003/02/06/bling/doggy.shtml
> ...snip...

Perhaps it doesn't have to be an error document? If I understand your
requirements, this rewrite rule should do it:

    # VirtualHost context assumed
    RewriteEngine On
    # Only continue if it is a request that can be handled
    RewriteCond %{REQUEST_URI} ^/news/([0-9]+/){3}.+/.+\.shtml$
    # and only if it doesn't exist
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /bling.cfm

I shortened the first pattern so it would fit on a line, but you may expand
it as you had it. You may also want to add the [R] flag to the last rule, so
it performs an external redirect to it. The original request is available in
the environment variable REQUEST_URI, or you could add it to the query
string of bling.cfm if you do an external redirect.

I have not tested it, but I have similar rules that work well. Joshua is the
mod_rewrite guru, so he may give some comments.

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message