Forum Moderators: coopster

Message Too Old, No Replies

Set REQUEST URI with URL parameter or a request header value?

REQUEST_URI not available on my server

         

jason1989

2:11 pm on May 25, 2008 (gmt 0)

10+ Year Member



My server does not support PHP's REQUEST_URI, so I'm thinking that I can do either of the following:

Option 1) Set REQUEST_URI value via a URL parameter on each HTTP request.

Option 2) Set REQUEST_URI value via a request header value on each HTTP request.

Unfortunately, I need to run a PHP application under IIS and the lack of this PHP var is the only barrier. Since my web server is missing that variable, I figure that I can manually set it.

I am not a PHP developer, but I don't think that doing this would be difficult.

If anyone could nudge me in the right direction, I would appreciate it very much.

Thank you,

Jason

jason1989

2:19 pm on May 25, 2008 (gmt 0)

10+ Year Member



I forgot to mention, that I know that there are PHP workarounds to simulate REQUEST_URI but those workarounds WILL NOT work when URL rewriting is performed under IIS.

The reason is that IIS does not transmit the original (pre-written) URL, it only sets the URL after it is written. Since the PHP app requires the original URL (as seen in the browser's address bar), the PHP have no way of knowing this.

This is the reason I wish to pass the pre-written URL via a URL param or via a request header.

Again, any thoughts or comments are greatly appreciated,

Jason

coopster

6:16 pm on May 26, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Can you use a different $_SERVER variable? Dump it to the browser to see:
<?php 
print '<pre>';
print_r($_SERVER);
print '</pre>';
exit;
?>

jason1989

12:13 am on May 27, 2008 (gmt 0)

10+ Year Member



Coopster,

Thanks for responding. None of the other PHP variables contain the original URL (before it is rewritten) under IIS.

I'm working on option #2 from my original post, so far it seems to be working very well.

Receptional Andy

7:17 am on May 27, 2008 (gmt 0)



Another workaround would be to make your internal rewrite create a query string (e.g. rewrite /path/file to index.php?p=/path/file). You could then access $_SERVER['QUERY_STRING'] or $_GET regardless of whether REQUEST_URI was available.

jason1989

4:49 pm on May 27, 2008 (gmt 0)

10+ Year Member



Andy,

Yes, option #1 was what came to mind first. After looking at the applications PHP code, I figured that option #2 would be my best route because I wouldn't have to change the application code.

BUT looking back though, option #1 would have been easier. Option #2 involved that I create an ISAPI filter that adds a request header containing the REQUEST_URI string. I called it ORIGINAL_URL, then assign it back to PHP's REQUEST_URI with each HTTP request.

Best Regards,

Jason