httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joshua Slive" <>
Subject Re: [users@httpd] redirect and rewriting puzzle
Date Mon, 02 Oct 2006 23:03:41 GMT
On 10/2/06, Dan Buettner <> wrote:
> Launched a new site last week, built on Rails, Apache and mongrel.
> Now have collected a number of 404 errors from the logs, and wish to
> redirect them to the appropriate page in Rails.
> My situatrion is, we're using URL rewriting to direct anything that is
> not a file to the mongrel Rail balancer.  But I wish to incorporate some
> 404 URLs which of course do not exist into the config.
> Is there a way to write a RewriteCond such that if a URL is not
> mapped/redirected in a file, THEN do the rewrite?
> My config:
>    RewriteEngine On
>    RewriteRule ^/(.*)$ balancer://prod_app%{REQUEST_URI} [P,QSA,L]
> (which leaves Apache serving static content and mongrel doing Rails)
> and later:
> Include /opt/csw/apache2/etc/general_url_redirect.txt
> Sample from the general_url_redirect.txt file:
> RedirectPermanent   /about/eventscalendar.htm
> What I'd like is to be able to do something aking to this:
>    RewriteCond ^(.*)$ $1!mapped:general_url_redirect.txt
> Suggestions welcomed.

You're looking at the problem from the wrong angle.

All you need to do is replace the RedirectPermanent in Include with
RewriteRule ^/about/evenscalendar.htm
and be sure to put the Include BEFORE the existing RewriteRules.  The
"L" flag stops rewriting at this point so it will never get to your
rails stuff.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message