• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3655
  • Last Modified:

Why is SCRIPT_URI missing in phpinfo() results.

This is my php file.
<?php phpinfo(); ?>

When this is run, SCRIPT_URI is missing from phpinfo() results.

On searching , I found this link : http://serv4.webcindario.com/webcindario/info.php
( webcindario.com is not my website)

The info.php seems to call phpinfo(); and it has :
SCRIPT_URI      http://serv4.webcindario.com/webcindario/info.php


When I do the same on my website, SCRIPT_URI is missing from phpinfo() results?

My website is hosted on a Linux server on shared basis.
PHP Version is 4.3.10
Apache Release is 10333100
Apache API Version is 19990320

Any suggetions why I am not getting value for SCRIPT_URI and how to solve it.

Thanks
0
playofwords
Asked:
playofwords
  • 8
  • 5
  • 3
  • +1
3 Solutions
 
peyoxCommented:
Do you get the script_uri with this?

<?
   echo $_SERVER['SCRIPT_URI'];
?>
0
 
playofwordsAuthor Commented:
<?
   echo $_SERVER['SCRIPT_URI'];
?>
returns nothing
0
 
peyoxCommented:
Apache handles this variable (script_uri). This is module responsible for this: http://httpd.apache.org/docs/mod/mod_rewrite.html
And it may be disabled (security?).

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
playofwordsAuthor Commented:
Here are the loaded modules, mod_rewrite is there:
Loaded Modules       mod_auth_passthrough, mod_log_bytes, mod_bwlimited, mod_php4, mod_frontpage, mod_ssl, mod_setenvif, mod_so, mod_auth, mod_access, >>>mod_rewrite<<<, mod_alias, mod_userdir, mod_actions, mod_imap, mod_asis, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_status, mod_negotiation, mod_mime, mod_log_config, mod_env, http_core

I have something like this in the .htaccess file and it is working:
RedirectMatch permanent ^/missing.htm$ http://domainname.com

( domainname.com is not my domain and used as an example.)

I have checked with the support staff of the webhosting firm and they say as RedirectMatch permanent is working, there is no problem with mod_rewrite.

This webpage mentions how mod_rewrite relates to SCRIPT_URI.  http://httpd.apache.org/docs/mod/mod_rewrite.html#EnvVar

If RedirectMatch permanent is working does it mean, mod_rewrite is not disabled and everything is working properly?

Is there some other way to confirm mod_rewrite is  working or not working properly, and if something has been disabled which is impacting SCRIPT_URI?

Thanks
0
 
lokipCommented:
SCRIPT_URI should get populated without mod_rewrite enabled, but you can try adding:

RewriteEngine on

to your .htaccess file.

0
 
playofwordsAuthor Commented:
RewriteEngine on is already there.
0
 
lokipCommented:
Are you by chance accessing via HTTPS?
0
 
playofwordsAuthor Commented:
No, just HTTP
0
 
lokipCommented:
Can I see the phpinfo() from your site?
0
 
playofwordsAuthor Commented:
The full page would be very long to copy here! is there something in  particular I could copy?
0
 
Marcus BointonCommented:
I note that SCRIPT_URI is not mentioned in the PHP docs:

http://www.php.net/reserved.variables

Can you not use $_SERVER['PHP_SELF'], $_SERVER['SERVER_NAME'] and/or $_SERVER['REQUEST_URI'] instead?
0
 
playofwordsAuthor Commented:
Thanks Squinky, Yes, your solution would be an alternate approach...

but I am hoping to learning why SCRIPT_URI value is not available on my shared hosting site.

Cheers
0
 
Marcus BointonCommented:
Given that it's undocumented, perhaps a better question would be why it IS available on your other server ;^)
0
 
lokipCommented:
The environment variables that Apache exposes can be tweaked significantly, so your shared host could have disabled it for some (very weird) reason. A few more google searches turned up similiar problems mostly on shared hosts. Have you tried contacting their tech support?
0
 
playofwordsAuthor Commented:
Squinky, It seems to undocumented in PHP but it seems to be part of Apache/mod_rewrite.but I am too new to web development to know details and why of all this.

lokip, The tech support fixed it but are not responding to request about details, as to why the problem was there in the first place, and what they did to fix it. I guess I might not  find out why till I run into this problem again with some other host, and hopefully they will tell me why!.

 peyox, Thanks for your link to mod_rewite  in apache docs.

Thanks to everyone who contibuted to this thread. I have increased the points and split them as input from all of you was essential in helping me understand the issue.. As SCRIPT_URI might not be available on all shared sites, I will use the suggestion provided by Squinky, to be on the safe side.

BTW, Squinky, can you please tell me which one to use PHP_SELF or REQUEST_URI, as both seem to return same value? what the difference between both. I read the explanations for both on http://in2.php.net/reserved.variables but the difference is not clear. I would appreciate if you would leave  a comment for this. Thanks
0
 
lokipCommented:
PHP_SELF and REQUEST_URI could be different if you are using any sort of module rewriting. IE, I have

/properties/search mapped to /users/prop/search.php using a RewriteRule

PHP_SELF will be /users/prop/search.php while REQUEST_URI will be /properties/search

Eric
0
 
Marcus BointonCommented:
Thanks lokip - I wasn't sure of that one!

I think that PHP imports all of apache's environment variables into $_SERVER, so if apache adds something new, it will also appear in PHP, but will not be documented within PHP.
0
 
playofwordsAuthor Commented:
Eric, Thanks for clearing it up!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now