I want to deny access to the js, css files
If someone trying to access such file.js or file.css
the website redirect him to 404
but below code is not working. because it even block serving web pages.
i just need to block access from js css files being browsed by users
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?mysite.com/ [NC]
RewriteRule .*.(js|css)$ - [F]
2
Answers
I’ve implemented the following script on my website for the same purpose. Could you modify your .htaccess file like this:?
.+.(js|css)$
that regex means match any files with the .js and .css extensions so it can also block valid requests for .js and .css files needed by your web pages.Try: