Force 404 for non existing sites

Discussion in 'General' started by David "Fires" Stein, Jul 11, 2024.

  1. David "Fires" Stein

    David "Fires" Stein New Member

    Hello, I know the default behaviour of Apache is that it serves the first HTTP web if it cannot find https for the requested domain. Is it possible to force the Apache to show 404? I disable the site for the client and then the customer is redirected to a different site, I want to show the 404 error page or better just do not serve any page. Thanks
     
  2. pyte

    pyte Well-Known Member HowtoForge Supporter

    Just remove the A-Record thats pointing to your webserver. Otherwise you need to configure the default virtual host to redirect to 404
    Code:
    Redirect 404 /
    ErrorDocument 404 "Page Not Found"
     
  3. David "Fires" Stein

    David "Fires" Stein New Member

    I change the default page in /var/www/html . Now I can send the 404 via PHP header and show custom 404 page. A record is one way but we do not have always the access to customer DNS. For the https I create a placeholder site aaa-ssl-placeholder.local, at the site is the PHP script that tries redirect back to the requested site just on HTTP, if it fails 3 times then is shows the error.
     

Share This Page