Forum Moderators: phranque

Message Too Old, No Replies

.htaccess: only allow access from certain files.

         

Sonnenblume

4:47 pm on Feb 12, 2008 (gmt 0)

10+ Year Member



Hi everyone.

I've got a bit of a problem (for me anyway seeing as I know very little about the workings of .htaccess). Essentially I am going to have a series of directories containing text files. I dont want anyone to be able to access these text files directly via the url (i.e. if they type [mysite.com...] I want an error to be displayed),

However, I do wish to allow certain files (namely 2 particular .php and .swf files) to have full access to the .txt files so they can read and output them. The .php and .swf files will be sitting in the root of the server.

Does anyone have any suggestions? I appreciate any help offered.

jdMorgan

5:26 pm on Feb 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This depends on whether the files need to be requested by the client, or if they are 'included' on the server side. .htaccess only controls HTTP access to a file, and has no effect on files that are 'read in' by other files on the server itself. So, if your .php and .swf files are simply doing local file reads, then you can deny all HTTP access to the text files with no effect on your .php and swf files' access to them.

Jim