Forum Moderators: coopster
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.
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.