How do I make Apache serve a single static page no matter what the entered URL is?

Solution 1:

In Ubuntu, make sure mod_alias is enabled:

sudo a2enmod alias

Then in your VirtualHost directive you can use AliasMatch.

Example:

<VirtualHost *:80>
    DocumentRoot /path/to/your/host
    ServerName yourdomain.com
    DirectoryIndex index.html

    AliasMatch ^/(.*)$ /path/to/your/host/index.html

    <Directory "/path/to/your/host">
      Require all granted
    </Directory>
</VirtualHost>

Now everything gets redirected to /index.html.

Solution 2:

You need a rewrite rule in your .htaccess file. Something like the following should work:

RewriteRule ^*$  http://www.addomain.com/index.html [R=301,NC,L]