0

I want to redirect the user to 404 error file while they try to access directories in my server such as imgs, js, css.

One Way I can put index.html to all those directories with 404 error.

Cons

I don't want to do this because their are alot of directories and sub-directories in my server.

Second Way Create a 404.html file and redirect every directory url toward it. How to acheive this this using .htaccess re-write rule?

1 Answers1

0

Create a 404.html file and redirect every directory url toward it. How to acheive this this using .htaccess re-write rule?

Try:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L,R=404]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220