Reputation: 31
I have few media files in a folder and a php file on same folder, I want to deny access for any media file accessing directly, but I want to access those media files only via the php file there.
lets say my_folder containing index.php, movie1.mp4, movie2.mp4 etc, I want to deny movie1.mp4 and movie2.mp4 straightly, but I need to allow by index.php
help me with htaccess handling
Upvotes: 2
Views: 1734
Reputation: 1028
You can ignore files using
RewriteRule ^/?/file\.mp4$ - [F,L]
You can use this as your .htaccess . All the request will be redirected to index.php in that directory & also all the request made to mp4 files will be redirected to index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?/file\.mp4$ - [F,L]
RewriteRule . /index.php [L]
</IfModule>
Upvotes: 2