Preventing public access to one file

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Preventing public access to one file

Post by alex.barylski »

I have something like:

Code: Select all

index.php
images/
documents/
Files under 'images' and 'documents' are meant to be publically accessible however index.php should NOT be viewable. How can I password protect that single file while still allowing publica access to files stored in sub-directories relative to it?

Possible?
Doug G
Forum Contributor
Posts: 282
Joined: Sun Sep 09, 2007 6:27 pm

Re: Preventing public access to one file

Post by Doug G »

You could use a wrapper index.php that includes the actual php code from a file that's not in a public directory.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Preventing public access to one file

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Preventing public access to one file

Post by alex.barylski »

Doug G wrote:You could use a wrapper index.php that includes the actual php code from a file that's not in a public directory.
WOuld need to change the design then...using Apache hacks I could just add to it.
Perfect. Thank you :)
Post Reply