My hosting server allows to host multiple websites.
The directory structure is like this

  • root
    |_ www.a.com
    |_ www.b.com
    |_ www.c.com
    |_ www.d.com

I want to put some PHP files on the www.d.com folder so if some one browse the site from web-browser can get it, but no one can get it's source code [even by loggin in to the root folder].
Is there any way to doing so ?
There is a feature called Password protect folder or so, can in help in this case ?

  • Ideally, you'd need separate (unix/linux) user accounts with access rights predefined including one for accessing the root folder.
    – James P.
    Commented Jun 27, 2011 at 8:44
  • 1
    This might be a little easier to answer all around if you mentioned who the host is. For example, separate ftp/hosting accounts is a valid suggestion, but some hosts don't even allow it.
    – Su'
    Commented Jun 27, 2011 at 8:49

2 Answers 2


I suspect "Password protect folder" puts a password on for people using web browsers. I think the best way to achieve this is to have separate ftp logons for the directories for a.com, b.com and c.com. Then only you, with access to the root, have access to the files for d.com. You could make the passwords the same so that people only have to remember one password.


PHP is executed on the server so if someone pulls up a PHP file in their browser the PHP will always execute and users will only ever see the output it creates. If you can see PHP code in your browser you either have a coding error or Apache is not set up properly.

If you want to make sure no one can see the files listed in these directories but still pull up the web pages, you can do that easily with .htaccess:

Options -Indexes
  • you got me wrong, i want to protect my codes from the other users who can login to the FTP/cPanel on the hosting server to access www.a.com |_ www.b.com |_ www.c.com
    – Sourav
    Commented Jun 27, 2011 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.