I want to add in my .htaccess ErrorDocument 404 /error-404.php (etc) but only when the referer is empty. So, if an user wrongly typed an URL, gets the error-404.php, but when I linked an image in my page and doesnt exists, the default error 404 apears.
That way, I save bandwidth not downloading HTML+CSS+stuff when the user wont see the Error.
But i dont know how to do it :(
Thank you in advance :)
Try this:
RewriteCond %{HTTP_REFERER} ^$
RewriteRule !error-404.php /error-404.php [L]
Don't set ErrorDocument
to the php file, otherwise your default 404 won't ever appear. Note that this won't return a 404 code by default, your error-404.php
needs to do this by using something like the header() function.