The easiest way is to use absolute urls / urls.
For URLs, define a constant / variable somewhere that points to the root of your application, for example:
define('ROOT_URL', 'http://www.example.com');
or
$root_url = 'http://www.example.com';
And use it in every link, for example:
<a href="{$root_url}/my-page.php">blah</a>
Thus, it is always OK (and on the day when you install the project on another server or in a subdirectory, you only have one constant / variable to change, and it still works)
For inclusion / necessity always use absolute settings; one solution is to use dirname , for example:
include dirname(__FILE__) . '/my_file.php'; include dirname(__FILE__) . '/../my-other-file.php';
__FILE__ - the current file in which you write this line; dirname gets the path (full path) to the directory containing this file.
With this, you never have to worry about the relative paths of your files.
Pascal martin
source share