Maintenance Mode in Kirby?

It’s not that simple unfortunately. The index.php is the starting point, but only a virtual one.

The actual URL the browser sees is for example http://example.com/ or http://example.com/projects/project-a.
If you then send a redirection header with a relative URL, the browser will resolve it relatively to the current URL, in the second case this will result in http://example.com/projects/maintenance.html, which will display a Kirby error page instead of the maintenance page even if maintenance is active.

1 Like

Thank you very much @lukasbestle!

You hints had been as customary absolute mandatory!

1 Like

Hi,
it would be nice if it would possible to use the global option from the site config also for this.
I have an option for develop as standard in my templates to switch some functions or files if the template is in developmode.
Or is there a possibility to overwrite all templates to another one like a maintenance template?

Another nice function would be if its possible to login on the maintance-file. So that allowed persons can see the website in development.
For this is use normal htpasswd. But with an maintance-file it looks better for people who are not allowed.

Cheers

Yes. You could conditionally register a route for the (:all) pattern if the maintenance mode is on. That route will always be called before any template and you can control whether to give control to the normal template or whether to return the maintenance page based on a logged in user.
Please note that this setup isn’t really useful when doing things like updating Kirby. A static HTML page in front of everything will work more reliably.

2 Likes