Forum Moderators: coopster

Message Too Old, No Replies

page name variable problem

php request_uri on www domain returns blank variable

         

huds

3:47 pm on Aug 13, 2005 (gmt 0)

10+ Year Member



Hi there,

Thought I had this cracked, but seems not.

I have some code that returns content based on the page name, e.g. index.php gives me main page content.

The trouble with this is that it works ok if www.example.com/index.php is the uri, but when only www.example.com is typed in the address bar then the php doesn't have a uri to fill in the filename variable.

Here's what I tried...

if ($_SERVER["REQUEST_URI"] == "")
$filename = "../index.php";
else
$filename = ".." . $_SERVER["REQUEST_URI"];

The funny thing was it worked the first time I tried it, but hasn't since.

Any help appreciated.

dmorison

4:46 pm on Aug 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



phpinfo() [uk.php.net] is your friend when it comes to this sort of problem.

In this case, I think $_SERVER["PHP_SELF"] or $_SERVER["SCRIPT_NAME"] may be more suitable as they will contain the actual filename of the script regardless of any internal re-write made by the web server.

huds

1:49 pm on Aug 14, 2005 (gmt 0)

10+ Year Member



It works now, Thank you very much indeed.