Getenv("REQUEST_URI");

Is there any reason why a server would not accept:

$init_uri=getenv(“REQUEST_URI”);

I am using some existing code and I do not think the server is retrieving the current url when it is called by this.

Any ideas?

Is there a reason you’re not using $_SERVER[‘REQUEST_URI’] ?

Sorry, I missed that part. I am using $init_uri=$_SERVER[‘REQUEST_URI’];

This worked fine on another server but it is not on the server I just moved the site to. Here is the code I have:

global $unit_uri;
$init_uri=$_SERVER['REQUEST_URI'];

while (strstr($init_uri,'//')) $init_uri=str_replace('//','/',$init_uri);

$init_q=strpos($init_uri,'?');
if ($init_q !== false) $init_uri = substr($init_uri,0,$init_q);

$init_q=strpos($init_uri,'#');
if ($init_q !== false) $init_uri=substr($init_uri,0,$init_q);

$init_uri = trim($init_uri,"/");
if (!$init_uri) $init_uri = DEFAULT_PAGE;

define('INIT_URI',$init_uri);

IIRC, IIS has issues populating this value. What web server are you using?

The domain is on a Linux server.

What is the web server, Apache? Is PHP running as a module, CGI, or FastCGI?

Are you using any rewrite rules?

No, that is th eonly code I have for the url recognition. I do not see anything else. I could be missing something but I do not see where it would be rewriting.

My apologies, I missed the previous question. There is no .htaccess file so I believe that means no rewrite rules. It is Apache suEXEC, and my php handler is DSO. dso and cgi are compiled but no fastcgi. my php version is 5. Does that help?

I just ran print_r($_SERVER); and this is what I got back - not sure if this helps?

Array ( [UNIQUE_ID] => TcXPeEPhooMAAEfrCJMAAAAM [HTTP_ACCEPT] => text/html, application/xhtml+xml, / [HTTP_ACCEPT_LANGUAGE] => en-CA [HTTP_USER_AGENT] => Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_HOST] => mydomain.com [HTTP_CONNECTION] => Keep-Alive [HTTP_COOKIE] => PHPSESSID=361762b44ad0c387dfc3d2a1bf11f8f8 [PATH] => /usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/courier-imap/sbin:/usr/lib/courier-imap/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin [SERVER_SIGNATURE] => [SERVER_SOFTWARE] => Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.13 [SERVER_NAME] => mydomain.com [SERVER_ADDR] => 67.225.162.131 [SERVER_PORT] => 80 [REMOTE_ADDR] => 99.249.242.95 [DOCUMENT_ROOT] => /home/mydomain/public_html [SERVER_ADMIN] => webmaster@mydomain.com [SCRIPT_FILENAME] => /home/mydomain/public_html/info.php [REMOTE_PORT] => 51973 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /info.php [SCRIPT_NAME] => /info.php [PHP_SELF] => /info.php [REQUEST_TIME] => 1304809336 [argv] => Array ( ) [argc] => 0 )

Just checking to see if anyone had any other ideas?

Sorry, I’m out.

After a few minutes searching, it appears CGI doesn’t populate REQUEST_URI. I did notice a post on the Wordpress support forum where you could repopulate it though, it might be worth a shot.

Other sources seem to hint at looking at argv in $_SERVER, but as you posted the array above, we can see it’s empty.

Let’s move this thread to the hosting forums, there’s some clever peeps in there. :slight_smile:

I’ve no idea eiher.
If I were in this situation I’d do a

var_dump($GLOBALS);

and see if there was anything I could use.
If not, it’s probably time to change some setting in the CGI or wherever, but I’ve no experience with that.

Thanks for the help. I think I may need to rewrite that portion of code.