Search code examples
apache2httpd.confurl-encoding

problem in apache httpd.conf with question mark character


I am have the following line in my httpd.conf file

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

the system respondes with

The requested resource (/servlet/StubEndpoint%3Fstub=stub/) is not available, ie it substitutes ? with %3F. How can I resolve that problem? That question mark seems to be substituted by "%3F" and I am getting back 404


Solution

  • From the documentation for ProxyPass:

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

    In your example, stub=stub is the query string. The %3F replacement is done as part of URL encoding.

    You may be able to proxy to a URL which is then redirected to the ultimate destination (with a querystring), something like:

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

    This should cause any URLs starting with /something to return a redirect to StubEndpoint?stub=stub. However I have not tested this myself.