2

I'm trying forward to another host when error occurs. I have this, and works:

<VirtualHost *:80>
    ServerName test.com.
    ServerAlias test.com

    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse /  http://127.0.0.1:8080/

    RewriteEngine on

    ErrorDocument 503 /503/

    RewriteCond %{REQUEST_URI} ^/503/$
    RewriteRule ^(.*)$ http://other.host.com/

</VirtualHost>

Now, when I have this URL: http://test.com/path/?param1=val1&param2=val2 and when 503 error ocurrs, I want redirect to new URL: http://other.host.com/path/?param1=val1&param2=val2.

It is possible forward /path/?param1=val1&param2=val2 to new host?

I have seen this and this, but it is not exactly my problem.

PS: I'm running a java application, not a php application

2 Answers 2

6

Since Apache 2.4.13, ErrorDocument can also use expression, so:

ErrorDocument 503 http://other.host.com/%{REQUEST_URI}?%{QUERY_STRING}
ProxyErrorOverride on
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @julp, this works! I didn't add ProxyErrorOverride on and worked too. I have upgraded apache to 2.4.20. Thank you very much.
0

Tested in shell script CGI and PHP on Apache 2.2

In shell script CGI, dump the /bin/env vars and grep REQUEST_URI,

In PHP, ret $_SERVER['REQUEST_URI']

This tip works for keep query string from httpd.conf settings redirected.

ErrorDocument 401 /errCode/401.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.