Forum Moderators: phranque

Message Too Old, No Replies

Protection of cached .inc files

semi public directory

         

ukgimp

9:22 am on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Imagine the scene, there is a directory on a publicly web accessible part of a website, into that folder cached versions of a db driven page are stuffed for later viewing. Is it possible to protect that directory with htaccess so that only requests from the script itself (on the server) are allowed to access the directory, whilst still allowing the caching script to read and write to the folder.

I imagine that the hotlinking type situation may be of assistance, but I am unsure of the specifics.

Eg

RewriteCond %{HTTP_REFERER}!^http://mysite.co.uk/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.mysite.co.uk/.*$ [NC]
RewriteRule .*\.(inc)$ - [F]

However that only protects .inc files from hotlinking. Will the * attribute work for everything. I only really need to stop people browsing.

Cheers

dcrombie

11:43 am on Jan 5, 2004 (gmt 0)



The following should be all you need:

RewriteRule \.inc$ - [F,L]

Any PHP scripts including the .inc files won't be affected _unless_ they include using a URL instead of a relative or absolute filepath.