Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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
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' Jun 27 '11 at 8:49

2 Answers 2

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

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

Your Answer

 
discard

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.