digitalFAQ.com Forum

digitalFAQ.com Forum (https://www.digitalfaq.com/forum/)
-   Website and Server Troubleshooting (https://www.digitalfaq.com/forum/web-tech/)
-   -   How to find the full path to your server directory, using a PHP file (https://www.digitalfaq.com/forum/web-tech/2492-how-find-full.html)

admin 10-18-2010 02:34 AM

How to find the full path to your server directory, using a PHP file
 
Sometimes you need to know the full path to a file or directory.
For example, if you wanted to setup .htaccess authentication, you'd need to enter the full path into the .htpasswd file.
If you don't know the full path, and PHP is installed on the server, then you can easily have the server tell you the folder location!

This small PHP script shows the full path of the file (the folder where the file is currently located on the server) when viewed in a browser
PHP Code:

<?php
echo dirname(__FILE__);
?>

Copy the code and paste it into a new file named pathtest.php. Either create the new file in your control panel, or create a local file and upload it via FTP -- either way is fine. Then view that file in your web browser (Firefox or Chroma is suggested, not MS IE). Example:
Code:

http://www.digitalFAQ.com/mytestfolder/pathtest.php
and you'll get something like this displayed in the browser:
Code:

/hosted/www/vhosts/mysite.com/subdomains/forum/httpdocs
That's an example of Linux.
Windows will be in a standard D:\vhosts\mysite.com\etc sort of location.

That's all you need.
When finished, for security purposes, delete that test file. You don't want to freely give hackers information about your site or server structure.

Hope that helps. :)


All times are GMT -5. The time now is 08:32 AM

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.