1

I get a POST request like /grabcontent?url=/foo/bar.html on my Apache server.

(yes, I know a POST request with a URL parameter makes no sense, but this is what I am getting from a 3rd party, cannot change this at the moment.)

/foo/bar.html is actually a valid page on my server.

How can I change this into a GET request to /foo/bar.html?

I know how to extract the URL parameter value, I know how to change the request internally using mod_rewrite. But how can I change the request from POST to GET internally?

I could write a dummy script that simply fetches content and map it to /grabcontent of course, but I would rather avoid the extra overhead and use Apache out-of-the-box functionality.

  • 1
    You don't need to convert the method from POST to GET as sending either to a static resource will simply result in that resource getting returned to the client. The static resource simply won't do any form of processing on the POST data and discard it... – HBruijn May 23 at 13:50
  • 1
    Not in my case as it goes to a Java application server. – Deeepdigger May 23 at 14:37
  • If you are going to be able to do this at all I would have thought you would need to do this at the point you send the request to the "Java application server"? How is this currently being achieved? Through a proxy? AFAIK you can't do this with mod_rewrite alone. Ordinarily you would do something like a 303 (or 302) external redirect and let the user-agent/browser reissue a GET request. But obviously this is "external", not "internal" to your server. And if the "3rd party" doesn't follow redirects (or does it?) it will just fail. – MrWhite May 24 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.