What I want is to be able to get the host and the sub-folder of a particular site. For example:
get http://example:81/test/
from http://example:81/test/pagename.php
.
It should also work with same url http://example:81/test/
and with multiple levels of sub-folders such as http://example:81/test/test2/somepage.php
.
It should not get the structure of the file within a folder itself such as http://example:81/test/images/page.php
should still be http://example:81/test/
and not http://example:81/test/images/
.
I tried using
$_SERVER['HTTP_HOST'] // only provides example:81
$_SERVER['REQUEST_URI'] // provides full path example:81/test/images/
Essentially I want to get is the url of the index.php file even if it is in a sub-folder.
Is there any way to achieve this?