I've configured Magento 2 website as maintenance mode from .maintenance.flag it's working, at the same time I have configured released IPs from .maintenance.ip file.

For multiple IPs not working while for single IP it's working fine.

How can I configure to release selected multiple IPs?

For this I have written I have created.

1) .maintenance.flag file from var.

2) .maintenance.ip file from var and written code for release single IP

For single I have written above it's working.,

For multiple, I have written above it's not working.

Can you please let me know how can I write to release multiple IP's and also how can I configure to redirect particular page while maintenance Mode?

  • 1
    I love this question. – Amit Bera Jan 5 '16 at 7:18

For activating maintenance mode with IP addresses execute below command in CLI

php bin/magento maintenance:enable --ip="" --ip=""

the above command will automatically create a .maintenance.flag and .maintenance.ip file under root/var folder.

and .maintenance.ip the file contains the above two IP addresses separated by a comma.

For more Information, you can find from devdocs.

The above information is for maintenance mode.

To redirect a custom page while maintenance mode writes below code in root/index.php.

$maintenanceFile =  __DIR__ . '/var/.maintenance.flag';

if (file_exists($maintenanceFile)) {

If anyone has better approach please update this answer.


The Maintenance Mode check-in lib/internal/Magento/Framework/App/Bootstrap.php. This file calls to lib/internal/Magento/Framework/App/MaintenanceMode.php. If .maintenance.flag file exists in var folder, it returns false.

If you want the redirect to a new page when maintenance enables, you need change lib/internal/Magento/Framework/App/Bootstrap.php file. Add this code below after line 288:

header('Location:'); //your page

protected by Community Oct 4 '17 at 20:29

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.