codeigniterhttp-redirectseohttp-status-code-503maintenance-mode

CodeIgniter redirect 503


I wanted to set a maintenance page for my website.

To do so, I check a field in the DB, in the first script running (MY_Controller). If it's on maintenance, I would like to redirect the user to the maintenance page. This works:

redirect("maintenance", 'location');

Here is my issue. I want to set the header code to 503 in order to avoid bots indexing the maintenance page in place of the real one. But whenever I do this:

redirect("maintenance", 'location', 503);

The maintenance page doesn't load, the URL doesn't change.


Solution

  • I think you can't set the 503 HTTP Status using the redirect() function that CI provides. But you can set the 301 code (temporal redirection), which means that the search engine will know that your page is temporally redirected and it will not index the maintenance page.

    More info here: http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html