Basically I’m trying to determine the complete web-accessible URL of a certain script, but without the script name.
For example, I was thinking of something along these lines:
$fullURL = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
echo $fullURL;
So if the file was http://example.com/path/to/file.php, then that’s what it would display: http://example.com/path/to/file.php. However, I want it to display http://example.com/path/to/
Is this possible, and if so, how?
Use the
dirnamefunction:This will exclude the last slash. You may of course append it yourself to match your preferences.