I want to configure the server to show a maintenance page when it exist. I tried this code and works:
location / {
try_files /maintenance.html $uri $uri/ @codeigniter;
}
But I noticed it would be served with a 200 status code, and it can cause confusion to search engines. I think the best practice would be returning a 503 status code. On google I find several relevant pages about it, like this. However, they use if to make the redirect and according to nginx documentation it isn't safe to use ifs.
Is there a way of doing it without using if? Is safe to use if in this case?
Thanks.