If you’re using apache and multiple vhosts on your webserver, you may have stumbled upon the difficulty to set the default vhost, and/or customizing it.
I’m managing a VPS and wanted to display a pretty page instead of a 404 error, and above all be sure that one vhost wouldn’t be served instead of another.
I created Apache-Fallback-Page, a simple symfony application with the following specifications:
- Easy to setup and install
- Multi-languages (english and french), the user should be redirected to the adequate language automatically
- Updatable with the Simple-Deployment-Script
The biggest deal here is to make sure that the vhost you’ll create will be the default one. As explained in the project’s README file,
apache2ctl -S command helps you debugging vhosts. It will output a list of all your vhosts in a specific order: the first one, marked as « default vhost » will be the fallback one. You’ll have to make sure that the Apache-Fallback-Page (or your own one) will live in this particular vhost.
Depending on your Linux distribution, Apache may be shipped with a default vhost named
000-default. You may have noticed its peculiar name: vhosts are sorted by name (and configuration file directory), so this one should be picked first. You may want to use this one and customize its content (by customizing pages in its
DocumentRoot). Please note that you should not set neither of its
ServerAlias directives or it wouldn’t be the fallback one anymore.
You can clone, fork and PR Apache-Fallback-Page on GitHub