I want to redirect all urls trying to access files in a folder to a common php page where I log the file being download and also checks whether the user is logged in or not, I’m trying the following way, but I’m not getting required result
Method 1:
RewriteEngine on
RewrteRule ^(.+)$ index.php?file=$1
Method 2:
RewriteEngine on
RewriteRule ^([a-zA-Z0-9\-]+)$ index.php?file=$1
My index.php
<php echo 'file - ' . $_REQUEST['file']; ?>
When I’m using the URL as http://localhost/next/files/Cool
Output Method 1 :
file - index.php
Output Method 2 :
file - Cool
Could you please tell me what is the wrong I’m doing in Method-1.
I could use Method-2 but the fileName could be anything [could contain all characters], so I need a regular expression which covers all [like in Method-1]
Regards
1 Answer