A WordPress website is made up from a number of files, organized in a number of sub directories. These files and sub directories are saved in a directory on a web server. This is the root directory of your site, also known as the document root.
Sometimes you need to find out absolute path of a directory on your WordPress site. The absolute path is the path of where a particular file or directory is saved on the web server. For example, if you are using .htaccess file restrict access to the WordPress dashboard, you need to specify the absolute path of the .htpasswd file (Apache password file) in the .htaccess file, otherwise the authentication files cannot be found.
This short article explains how you can find the absolute path of a website directory.
PHP script to find absolute path
Here is a simple one line PHP script you can use to find the absolute path of the directory on your web server.
&amp;lt;?php echo getcwd(); ?&amp;gt;
How to find the absolute path of a directory on your website
- Save the above PHP script to a file, for example path.php,
- Upload the file path.php to the directory of which you want to know the path,
- Launch a web browser and navigating to the script e.g. http://www.example.com/directory/path.php