Re: Redirect to other server if file/directory does not exists.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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]


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux