We often have to put our sites in maintenance. If our sites run Magento 2 we can this in traditional method i.e using htaccess file and rewrite rules. But there is also a simpler way to do this.
With Magento 2 we do not have to fiddle with htaccess or rewrite rules. We can do this with a simple command
bin/magento maintenance:enable
We must be in the magento root directory to run this command.
If we want to allow users from certain IPs to access while in maintenance mode run
bin/magento maintenance:allow-ips <ip address> .. <ip address>
instead of using two command one to enable and then to add IP, we can do
bin/magento maintenance:enable --ip=<ip address1> ... --ip=<ip address2>
To disable maintenance mode and put the site live again run
bin/magento maintenance:disable