How to find the absolute path of a folder/directory on a server.

Finding the absolute path on a server can be hard. If your installing a website with a CMS like Joomla, Drupal, Mambo etc or a blogging platform like Wordpress you may need to put the path to a folder in some configuration file.

Of course you may not know exactly what the path is because every server/host is different. Sure you probably know the root path (the path you start in when connected by FTP) but that path is usually within other folders on the server. This method is to find out the actual (real) path of a folder.

In Joomla it is very common that when you move you Joomla site from one host to another you will need to change these variables in cinfiguration.php
var $log_path = '/your_absolute_path/logs';
var $tmp_path = '/your_absolute_path/tmp';

Start by creating a text file in notepad. Put the following code inside it:

$path = getcwd();
echo "Your Absoluthe Path is: ";
echo $path;

Save the file with any name (save it as encoding ANSI) and the extension .php (test.php, path.php etc)

Navigate to the folder you want to find the path for and upload it/save it there.

Now go to you browser and run the php file from the web location. If for example you had the file and you wanted to know the absolute path on the server for then save the php file there and run it like this (if you name the file path.php).

The information shown on the screen will be the absolute path on the server of you root directory for that site. You can put the file anywhere to find out what the absolute path is.

When you are finished, delete the file because it represents a security risk.

Next time someone asks "how do I know what the actual/absolute path is on the server arrrgh!?" you'll be able to help!

Posted in Joomla