← ServerPilot Docs

How to Set the Default App

If your server is configured to allow requests for domains that don't belong to any of the apps on your server, those requests will be handled by your server's default app (sometimes called the default site).

Tip: Add your server's IP address as an app's domain name to preview the app.
You don't need to enable the default app to preview an app using your server's IP address. Instead, add the server's IP address as one of the app's domain names.

Enabling the Default App

To enable the default app, go to your server's Settings tab and click the switch for "Deny requests for unknown domains" so that it is disabled (grey). This allows requests for unknown domains to be handled by your server's default app.

With this setting instead enabled (green), requests for any unknown domains are instead rejected by your server.

Which App Is the Default?

The default app is the app whose name is alphabetically first.

If you have two apps on your server, foo and bar, then the app bar will be the default because bar comes alphabetically before foo.

Creating a Default App

If you want to create an app that is always the default, create an app named 0default (a zero followed by the word default). As long as none of your other apps start with a zero, this app will be the default.

If you need to redirect requests from the default app to one of your other apps, enable the default app as described above and then create a .htaccess file in the 0default app's web root directory with the following contents:

RewriteRule .* http://example.com [R=302,L]
You can change the 302 to a 301 after you have confirmed your redirect is working as expected and you are ready for it to be cached by browsers.
Last updated: July 21, 2017

Launch your first site in 5 minutes