Here's my solution, simple, clean and efficient for all URL requests and SEO respects:
Add these variables to: application /Config/config.php
$config['maintenance_mode'] = TRUE; $config['maintenance_ips'] = array('0.0.0.0', '1.1.1.1', '2.2.2.2');
Add this condition at the end: application /Config/routes.php
if(!in_array($_SERVER['REMOTE_ADDR'], $this->config->item('maintenance_ips')) && $this->config->item('maintenance_mode')) { $route['default_controller'] = "your_controller/maintenance"; $route['(:any)'] = "your_controller/maintenance";"; }
Create method support in: application / controllers / your_controller.php
function maintenance() { $this->output->set_status_header('503'); $this->load->view('maintenance_view'); }
Create view: app / views / maintenance_view.php
<!DOCTYPE html> <html> <head> <title>Maintenance</title> </head> <body> <p>We apologize but our site is currently undergoing maintenance at this time.</p> <p>Please check back later.</p> </body> </html>
source share