Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
Ideally, you'd need separate (unix/linux) user accounts with access rights predefined including one for accessing the root folder. – James Poulson Jun 27 '11 at 8:44
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' Jun 27 '11 at 8:49

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.

share|improve this answer

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
share|improve this answer
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 Jun 27 '11 at 4:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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