Cannot remove Apache2 Ubuntu Default Page

Solution 1:

The Apache code (httpd.h file, in particular) sets a default location of documents, which can be overwritten by the DocumentRoot directive. Depending on the installation, the Apache source code includes lines like the following:

#ifndef HTTPD_ROOT
#define HTTPD_ROOT "/usr/local/apache"
#endif

#ifndef DOCUMENT_LOCATION
#define DOCUMENT_LOCATION  HTTPD_ROOT "/htdocs"
#endif

Because a default installation will also generally include a default index.html (and also default in the permissions settings to allow access the relevant directory), you can still be served a default page even if you remove all of the default sites. In order to prevent this, in favor of an error, you will have to set a default DocumentRoot that has no "index" type file or for which permission is denied, or you will have to remove such files from the directory that your installation defaults to in the Apache code.