How to configure an Apache rewrite-rule to redirect all requests to 404 unless explicitly allowed
Just try this line in your .htaccess file:
RewriteRule ^(?!(allowedFile\.html|allowedDirectory/)) - [R=404,L,NC]
Above rule will throw 404 for everything except a file called allowedFile.html
and a folder called allowedDirectory
.