【问题标题】:problem in apache httpd.conf with question mark characterapache httpd.conf 中带有问号字符的问题
【发布时间】:2011-05-06 03:57:13
【问题描述】:

我的 httpd.conf 文件中有以下行

ProxyPass /something http://localhost:9080/servlet/StubEndpoint?stub=stub

系统响应

请求的资源 (/servlet/StubEndpoint%3Fstub=stub/) 不可用,即它替代了 ? %3F。我该如何解决这个问题?那个问号似乎被“%3F”代替了,我得到了 404

【问题讨论】:

    标签: apache2 httpd.conf url-encoding


    【解决方案1】:

    来自ProxyPass 的文档:

    url is a partial URL for the remote server and cannot include a query string.
    

    在您的示例中,stub=stub 是查询字符串。 %3F 替换是作为URL encoding 的一部分完成的。

    您可以代理到一个 URL,然后将其重定向到最终目的地(使用查询字符串),例如:

    ProxyPass /something http://localhost:9080/proxy
    RewriteEngine on
    RewriteRule ^/proxy /StubEndpoint?stub=stub
    

    这应该会导致任何以 /something 开头的 URL 返回重定向到 StubEndpoint?stub=stub。但是我自己没有测试过。

    【讨论】:

    【解决方案2】:

    我喜欢按位置分组。我的工作解决方案是:

    <Location /something>
        RewriteEngine On
        RewriteRule ^ http://localhost:9080/servlet/StubEndpoint?stub=stub [P]
    </Location>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-10
      • 1970-01-01
      • 2020-05-06
      • 2011-09-26
      • 2019-06-29
      • 1970-01-01
      • 2016-11-25
      相关资源
      最近更新 更多