Search code examples
phpcodeigniterseo

Route all visitors to Codigniter Built Website to specific controller and method


I have a website built on top of codeigniter and I want to take the website down temporarily to make changes. I would like to accomplish this by creating a white-list of approved IP addresses that can access the regular website while I make upgrades, and all other users would be routed to a temporary page. What's a good strategy for dealing with this? Perhaps something using the routing class?

    $whitelist = array('99.999.999.999', '555.555.555.555');
if(!in_array($_SERVER['HTTP_X_REAL_IP'], $whitelist))
    $route['(:any)'] = 'maintenance/index/';

I also don't want to destroy my search engine indexing, so should I send a specific header to signal that this is a temporary change?


Solution

  • I think you are going down the right path with the routes.php changes you are thinking about. The server should use a 503 response code. That will tell search engines you are temporarily down for maintenance and that they should not index the pages.