Forum Moderators: coopster
Here's the offending code:
<div id="rate-site"<?php if ( $_SERVER['REQUEST_URI']=='/' ) echo ' class="invisible"'; ?>>
This is used to make the "rate-site" page element invisible on the home page, e.g. when the browser requests "http://localhost/wheremysiteis/"
However - it just doesn't work. When I go to that URL, that's exactly what shows in the URL bar (it doesn't resolve to /index.php or anything) and I also tried replacing '/' with '/index.php' or '/index.php/' - makes no difference.
The code was originally written for PHP4, so maybe this function behaves differently in PHP5?
Help... hopefully it's something simple and dumb.
Thanks,
Joe
Instead of using $_SERVER['REQUEST_URI'], try to use $_SERVER['SCRIPT_NAME'] - in this case you will always be provided with the requested script name, no matter of the request URL.
In other words, no matter if the client visit your website through http://www.example.org or http://www.example.org/index.php you always now the script name, which the server executes.
Also note, if this script running in a subdirectory, as you show:
[localhost...]
The $_SERVER['SCRIPT_NAME'] value will be sort of: "/wheremysiteis/index.php"
The SCRIPT_NAME will not contain any parameters, passed to the page (e.g.: index.php?id=32 ) but the REQUEST_URI will contains them all!