I wish to redirect only when there's a mistake (server status 503). With no error, this is actually the redirect script, which works fine:
Redirect /abc https://www.abc.com/pqr.html Redirect /cde https://www.cde.com/pqr.html
But, this redirects /abc to https:// world wide web.abc.com/pqr.html in most cases. I would like this redirect only just in case of the error. This syntax:
ErrorDocument 503 https://www.abc.com/pqr.html
redirects all web addresses with 503 error message to https:// world wide web.abc.com/pqr.html. But, I would like the /cde ones with 503 error messages to become rerouted to https:// world wide web.cde.com/pqr.html
Any clues regarding how to get it done?
Well to begin with let us realize that ErrorDocument directive is unconditional and can't be wrapped around
if cond then ErrorDocument kind of expression inshtaccess.
However there's a workaround to accomplish this. For your you have to capture individuals conditions using mod_rewrite which should redirect utilizing a custom error code. And you might have ErrorDocument for you personally own custom error code. For ex:
RewriteRule ^cde/invalidUrl - [L,R=425] ErrorDocument 425 https://www.abc.com/pqr.html
By doing this above ErrorDocument will impact only
/cde/* URIs and won't impact other URIs.
This perfectly works best for me. Got this answer in Apache Forums:
<VirtualHost x.x.x.x:80> ServerName www.mysite.com <Location /books> ErrorDocument 503 http://www.mypartnersite.com/books </Location> <Location /music> ErrorDocument 503 http://www.mypartnersite.com/music </Location> ... </VirtualHost>