Forum Moderators: phranque

Message Too Old, No Replies

Rewrite error

         

Shanna7463

10:38 pm on Nov 14, 2007 (gmt 0)

10+ Year Member



Hello, I was originally using a proxy to forward my requests to another URL, however because the URL had a '?' in it, it would convert that into %3F, thus causing a 404 error.

So now I'm trying to use mod_rewrite to forward [mysite.com...] to [mysite.com:9000...] This works when I have:

RewriteRule ^/myfile/(.*)$ [mysite.com:9000...] [R]

However, I also want to manipulate the URL so that you continue to see [mysite.com...] so I add:

RewriteRule ^http://mysite:9000/(.*)$ [%{SERVER_NAME}...] [PT]
(This RewriteRule worked when I was using ProxyPass with a URL that had no '?')
When I add the second RewriteRule I get a 400 Bad Request Error.

What am I doing wrong? If its possible to fix the Proxy so that it doesn't change '?' to %3F, I would love to know how!

Thanks in advance!

-- Shanna --

[edited by: Shanna7463 at 10:52 pm (utc) on Nov. 14, 2007]

jdMorgan

11:26 pm on Nov 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteRule cannot normally "see" the "http://mysite:9000" protocol, domain, and port number. It sees only the local URL-path matched here by "/(.*)".

So this rule will only work if there is a preceding rule that adds the protocol, domain, and port number, and does not end with a [L] flag.

Further, if that is the case, then one could argue that either the second rule isn't necessary, or that the whole method needs to be re-examined. While in some cases, it's best to keep threads limited to single small-scope questions, this project argues more for a complete description of the project.

If you don't want to expose the back-end URL, you cannot use external redirects at all; no amount of after-the-fact fix-up will 'unexpose' the back-end URL once the client has seen it.

Note that you can do a reverse-proxy throughput directly from mod_rewrite by using the [P] flag; This may help you to simplify your implementation.

Jim