httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Montague <>
Subject Re: [users@httpd] mod_rewrite redirect to different server
Date Tue, 20 Sep 2011 04:12:18 GMT
On September 19, 2011 15:34 , =?ISO-8859-15?Q?Bernd_Sch=F6nbach?= 
<> wrote:
> is it possible to write a mod_rewrite rule, which reroutes requests to
> another server, if they are not found on the current server e.g.:
> Requested URL:
> Backup URL:
> The redirect should only be made if the Requested URL delivers a 404
> message.

You can do what you want using mod_rewrite:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$1 [R,L]
See for information on how to 
use mod_rewrite.

Alternatively, you could set up an ErrorDocument on your server to 
handle all 404 errors.  Have this ErrorDocument be a script that gets 
the URI path the user was trying to access from the REDIRECT_* 
environment variables and then prints HTTP response headers to redirect 
the user to the appropriate URL for  For details, see

   Mark Montague

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