Howto get the relative path of a file / folder in Unix / Linux with PHP

Sometimes you´ll need the relative path of a file or folder stored on your webserver. Especially if you´re one a shared environment this can be a bit tricky sometimes.

Here is a short and easy solution for your problem:

  • create a php file named ‘fullpath.php’
  • open the file and enter the following php code
  • <?php
    $dir = dirname(__FILE__);
    echo "<p>Full path to this dir: " . $dir . "</p>";
    echo "<p>Full path to a .htpasswd file in this dir: " . $dir . "/.htpasswd" . "</p>";
  • upload the file to the folder on your webserver which you want to know the path (f.e.
  • open your webbrowser and go to the location you´ve uploaded the file (f.e.
  • enjoy your relative path (which could look f.e. something like this  ‘/var/www/vhosts/’)
  • Note: if you plan to use this relative path for other applications you may need to add an additional ‘/’ at the end (‘/var/www/vhosts/’)


God Mode in Windows 7

If you want to have all your system parameters and everything that can be adjusted within Windows 7 in one big folder, then you should create  the following directly on your desktop :

Desktop => New Folder => Name “XYZ” + “.{ED7BA470-8E54-465E-825C-99712043E01C}”

The new folder can have any name you want (in this case it´s “XYZ”) and you need to add this string to the folder name (including the point). When done, the symbol of the folder will change and when you double click it, you have everything you want in one big folder.

Note 1 :

This also works with Windows Vista but several crashes of the explorer have been reported, so use it only carefully.

Note 2 :

If you don´t want to mess up your desktop with a soo long folder name you can also create it in a subfolder on your desktop. But – some people reported crashes, so use it carefully.