0

I'm trying to use mod_rewrite and somehow forward - preferably via a header - the original URI to my application server.

What I'm really sticking up on is how to get the information I send to carry over from the client after they follow the redirect to the application server.

The only method I've come up with is passing a get request with original URI, but that seems ugly.

Note - I already reviewed Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About Mod_Rewrite Rules but Were Afraid to Ask and Crazy Advanced Mod_Rewrite Debug Tutorial

It's possible I overlooked something; if so please give me the right term and close as a duplicate. :)

EDIT:

mod_rewrite is using a 302 redirect to the application server. The actual redirect is client side. Some of the domains match, others don't. The basic syntax of my rules looks like the following.

RewriteCond %{HTTP_HOST} mydomain|myalias
RewriteRule ^ http://www.mydomain.org... [R=301,L]
Tim Brigham
  • 15,465
  • 7
  • 72
  • 113

1 Answers1

1

At the beginning of your rewrite rules, save the URI into a variable. I'll call it ORIGINAL_URI.

RewriteRule (.*) - [E=ORIGINAL_URI:$1]

Is Apache directly passing this request along to the application server? If so, set a custom header, which I'll call Original-URI, to the value of that variable.

RequestHeader set "Original-URI" "%{ORIGINAL_URI}e"

Is Apache sending a redirect back to the client, which will then issue a new request? As long as the domain stays the same, you could tell the client to set a cookie.

Header set Set-Cookie "Original-URI=%{ORIGINAL_URI}e"
sciurus
  • 12,493
  • 2
  • 30
  • 49