I am using Apache2 as web server in Ubuntu and my root is /var/www/html. In there I have an .htaccess file with
RewriteEngine on
ErrorDocument 404 /custom404.html
in it. This works. When I visit mydomain.com/arandomstring I see the custom404.html page. However, what I want to do is block direct access to custom404.html like domain.com/custom404.html should not work. How would I achieve this? I have searched StackOverflow extensively but found no help in this regard.