ratthing

I am trying to keep the visitor's initial URL requested available they can be redirected there after they go through an age gateway.  Scripting for the gateway is

PHP

 ; the URL is getting rewritten to force them to the age gateway, so I'm getting that in my $_SERVER['REQUEST_URI'] rather than the original request.  Any suggestions on any other tactic that might work in

PHP

 ?  I didn't see anything obvious from the docs.

It looks to me like I'll need to use mod_rewrite to add a query string containing the originally requested URL to be able preserve it, or am I barking up the wrong tree?  I was hoping to avoid a lot of mod_rewrite fiddly bits, but I can't think of any other way to handle it.

Thanks for any pointers--
=RT=

perkiset

I think I understand what you're saying RT, let me know if not - I think you're asking how to keep the complete original URL when you reverse-proxy a request inbound towards another HTTP server. If this is correct, then you are as well - in

Apache

  you'd mod_rewrite to the internal URL where the request needs to be handled, and append the original URL as a query param so that you can make use of it at the destination.

Here is and example of two things: a mod_rewrite that throws a proxied request to a renderer behind the public

mac

 hine, as well as using a rewritemap to define *which

mac

 hine* is the destination for load balancing. In this case, there is a small file called cluster_btd which defines which

mac

 hines (defined by a hostname) are to be used as "online" for the virtual host. In the example below, all requests (I mean ALL requests) are handled by a single entity, the important part of this rewrite is the get params:


        RewriteMap              cluster  rnd:/www/resource/db/cluster_btd
        RewriteRule ^(.*)$ http://${clusterApplausenline}$1?__site_id=SBTD1.0002&origip=%{REMOTE_ADDR}&port=%{SERVER_PORT} [P,L,QSA]


The cluster_btd file looks like this:
online    rcluster_01|rcluster_02|rcluster_03|rcluster_04|
stage      rcluster_05

so if someone requests a page,

Apache

  will randomize rcluster_01 .. rcluster_04 and send the request backwards. If a call comes through for stage.thedomain.com then it is passed to a different

mac

 hine. I have little text file editor scripts that allow me to define which

mac

 hines are in production and which not, so if something is failing me I can take it out of the production site simply by changing the names in the text file.

Sory if this post makes no sense, I'm going fast between sessions at the PubCon... ping back if I completely confused you Applause

ratthing

More investigation and your comment confirms my line of thought.  While in this instance, what I termed a "gateway" is actually just another script, I really should just think of it as a reverse proxy-like environment (since I've done that and have some clues about it  :dohApplause.

Mod_rewrite twists my brain into knots for some reason.  Hopefully your example it will help me sort out where I am going with this.  Currently there is only one potential destination past the age check script, so I've gone 80/20 route for the mo.

Thanks again, Perk.
=RT=


Perkiset's Place Home   Politics @ Perkiset's