httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Igor Cicimov <icici...@gmail.com>
Subject Re: [users@httpd] Redirect to other server if file/directory does not exists.
Date Tue, 05 Aug 2014 12:40:52 GMT
>
> RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
> RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
> RewriteCond %{REQUEST_URI} ^/(.*)$
> RewriteRule ^/(.*)$ http://other-server/%1 [P,L]
>
> Does not work. Local resources if esists are shown, but remote resources
> are 404 not found "/". Nor %{REQUEST_FILENAME} helps.
>

You have probably some other rule interfering before this one. Anyway,
enable mod_rewrite logging and check in the logs what's going on.

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog

See RewriteLog and RewriteLogLevel.

Also no need of the 3rd RewriteCond, since you want to use the REQUEST_URI
just write:

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ http://other-server%{REQUEST_URI} [P,L]

Mime
View raw message