I want to display a 404 Error if a user reaches a page that exists but I don\'t want him/her to see.
I don\'t want to do redirect (that would cause the address bar t
In my experience the best way to show 404 error document without changing URL is to define error document in apaches .htaccess file:
RewriteEngine on
RewriteBase /
# Defines 404 error pages content:
ErrorDocument 404 /my_root/errors/404.html
# for all invalid links (non existing files):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* - [L,R=404]
# for some valid links (existing files to be un-accessible):
RewriteCond %{THE_REQUEST} ^.*some_file.php.*$ [NC]
RewriteRule .* - [L,R=404]