发生错误时,我正在尝试转发其他主机。我有这个,并且有效:
<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>
现在,当我有这个网址时:http://test.com/path/?param1=val1¶m2=val2
当503错误发生时,我想重定向到新网址:http://other.host.com/path/?param1=val1¶m2=val2
。
可以将 / path /?param1 = val1&amp; param2 = val2 转发给新主机吗?
PS:我正在运行一个java应用程序,而不是一个php应用程序
答案 0 :(得分:4)
自Apache 2.4.13起,ErrorDocument也可以使用表达式,所以:
ErrorDocument 503 http://other.host.com/%{REQUEST_URI}?%{QUERY_STRING}
ProxyErrorOverride on
答案 1 :(得分:0)
在Apache 2.2上的Shell脚本CGI和PHP中进行了测试
在shell脚本CGI中,转储 / bin / env vars和grep REQUEST_URI
,
在PHP中,退出$_SERVER['REQUEST_URI']
此技巧适用于保持重定向httpd.conf设置中的查询字符串。
ErrorDocument 401 /errCode/401.html