I am using .htaccess
to prevent user to access files through url.
The line
RewriteRule ^frontend/assets/css/(. ) index [L,R]
works fine. It prevents users to access css files.
However,
RewriteRule ^frontend/assets/images/(. ) index [L,R] //Images
as well as
RewriteRule ^frontend/assets/js/(. ) index [L,R] //Javascript files
do not work.
I have tried multiple solutions but still I can access js
and images (png and svg)
files from the url.
Is there a way to handle this ?
CodePudding user response:
Please following rules at the top of your htaccess rules file. You need not to create 3 separate rules for 3 conditions, you can use regex here and can do a 401 redirect for all of 3 strings(js/images/css) in a single rule itself.
Make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^frontend/assets/(?:images|css|js) - [R=401,NC,L]