Thanks Joshua. Worked out great.
Dan
Joshua Slive wrote:
> On 10/2/06, Dan Buettner <danb@thelittlemacshop.com> 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
>>
>> RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
>> 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
>> http://www.site.com/calendar
>>
>> 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 http://www.site.com/claendar
> [R=permanent,L]
> 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.
>
> Joshua.
---------------------------------------------------------------------
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
|