...

View Full Version : htaccess deny all, allow php's readfile()



LordV
04-20-2009, 05:50 PM
Hey all,

I'm trying to create a htaccess file that will do the following: it has to deny access to all .split files (located in subfolders). In addition it will allow the 'dl.php' file to read the .split files (php's readfile() function (or fopen() or ...)).

The folder structure:

something
| -- .htaccess
| -- dl.php
|
| -- example1
| | -- 0.split
| | -- 1.split
| ` -- 2.split
|
| -- example2
| -- 0.split
| -- 1.split
` -- 2.split

At this site (askapache.com) (http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html) I found this snippet:

Deny access to anything in a subfolder except php fopen
This can be very handy if you want to serve media files or special downloads but only through a php proxy script.

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/.*\ HTTP [NC]
RewriteRule .* - [F,L]
but I'm new to htaccess (and regexp :p) so I've no clue how to edit the script so It'll work (I tried).


Thanks in advance.

I forgot to tell, anyone should be able to access the dl.php file...!

schleppel
04-26-2009, 07:58 PM
Try

<FilesMatch ".\.split$">
Dent from all
</FilesMatch>

LordV
04-27-2009, 03:59 PM
Hey,

Suppose it's 'deny' instead of 'dent'? At any rate, it worked! Perfect. And so simple... :p

Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum