chmod newbie question

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
winxp.tar.gz
Forum Newbie
Posts: 3
Joined: Wed Jun 18, 2008 2:06 am

chmod newbie question

Post by winxp.tar.gz »

hello everyone,

sorry for a noob question, but i was wondering if I could chmod a txt file (eg. test.txt) to make it unreadable for everyone trying to get it via http:

http://my.domain.com/somefolder/test.txt

so it would display a 403 forbidden error. but still i'd like to be able to get its contents in a php script.

i tried a few combinations but i ended up with being able to read it via http AND php script, or not being able to read it at all.

any solutions?

winxp.tar.gz
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: chmod newbie question

Post by Mordred »

It looks like you're doing it from the opposite direction, and since usually PHP runs as Apache module, denying Apache you deny PHP as well.
Try the reverse: deny HTTP access with .htaccess (RTF

Code: Select all

M), and leave the file with its regular chmod bits so the PHP can read it.
Post Reply