edwardmp
edwardmp

Reputation: 6611

Using htaccess to protect files

I am using htaccess to protect uploaded files from being available publicly (only logged in users can see the files).

My current htaccess consists of:

RewriteEngine on
RewriteRule ^(.*).(pdf|exe|doc|jpg|jpeg|png|gif)$ access.php?file=$1.$2 [L]

This works, however my folder structure is as following:

access.php
--------------files
---------------------file
---------------------photo

So, in the same dir as access.php is a subdir called 'files', and in files are 2 subdirs file and photo.

How can I capture a more complete path of the file in the htaccess? Example: files/file/a.jpg Now it only returns a.jpg

Upvotes: 0

Views: 149

Answers (1)

rekire
rekire

Reputation: 47985

Try to add a rewritebase so the result should an absolute URL:

RewriteBase /

Upvotes: 1

Related Questions