I'm having dubts on my website's structure. I've a config, lib and public folders in the root. config contains the config.php and other similiar, lib contains all php/html content (header, each page content, footer etc), while public folder contains all the subfolders for each page with the index.php inside. I did this for the url... Anyway, each of these index.php set their page name in a variable and call the config.php file and a module.php for the whole content. My problem is that since I have multi level subdirectory (news/sport/football) each index.php have different config path to call. The "deepest" files have many "../" before config/config.php.
Here's the index.php inside public/news/:
<?php
require '../../config/config.php';
$MainPage = 'news';
$CurPage = 'news';
include_once(LIB_PATH. 'modules.php');
?>
So, is there any way to get the absolute root dir so that the path is the same in all files? Also, is this structure correct?