How create BASE URL of website if the menu are in different folder?

Viewed 579

I know it is stupid to do but I have the situation that I create menus in different folders. And I tried to create the baseurl for menu.

function getBaseUrl() 
{
     $currentPath = $_SERVER['PHP_SELF'];
    $pathInfo = pathinfo($currentPath);
    $hostName = $_SERVER['HTTP_HOST']; 
    $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://';
    return $protocol.$hostName.$pathInfo['dirname']."/";
}

Use base url like <?php echo getBaseUrl(); ?>. My problem is:

Let I have menus aaa bbb ccc ddd. And page of aaa menu is inside folder1/page1.php

page of bbb menu is inside folder2/page2.php. I can't go from aaa menu to bbb menu.

Any one have Idea? please suggest

2 Answers
Related