使用Apache中的ErrorDocument将请求参数转发到自定义404页面? [英] forward Request parameters to custom 404 page using ErrorDocument in apache?
问题描述
是否有一种方法可以使请求参数转发"到apache中的自定义错误文件,就像[QSA]对重写规则所做的一样?
Is there a way to have the request parameters "forward on" to the custom error file in apache much like [QSA] does on rewrite rules?
如果我发送www.foo.com/doesnotexist?bar=true
if i send in www.foo.com/doesnotexist?bar=true
我在虚拟主机中有这个
ErrorDocument 404 /customerrorpage
然后它将通过以下方式调用customerrorpage:
then it would call customerrorpage with:
customerrorpage?bar=true
推荐答案
我知道这确实是个老问题,但尚未得到解答,因此,如果有人在网站上寻找答案,我会分享一下我知道.
I know this is really old question, but it hasn't been answered and so in case someone else is searching the site for the answer I'll share what I know.
Apache 2.2 ErrorDocument页面指出,当您具有自定义错误页面是本地页面,然后将设置许多环境变量,这些变量可以从您的客户错误处理程序中读取.变量之一是REDIRECT_QUERY_STRING,它将包含原始页面具有的查询字符串.因此,在您的示例中,REDIRECT_QUERY_STRING将包含"bar = true".
The Apache 2.2 ErrorDocument page says that when you have a Custom Error page which is a local page then a number of environment vars will be set which can be read from your customer error handler. One of the vars is REDIRECT_QUERY_STRING which will contain the query string that the original page had. So in your example the REDIRECT_QUERY_STRING would contain 'bar=true'.
这篇关于使用Apache中的ErrorDocument将请求参数转发到自定义404页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!