How to put Magento in Maintenance Mode only for Front end
In this tutorial we will show you how to put your Magento online store in maintenance mode only for front end site. The admin can access the site without any issue
To put a Magento site in maintenance mode, you need to create an empty maintenance.flag file and upload it to the root folder of your site.
When you will upload maintenance.flag file then your website will be down and will show the error message
Service temporarily unavailable.
So for this message will show for all types of users. Now we will come to point and restrict the above message only for front users. For this follow the below instructions :
You need to replace the below code in index.php file (keep in mind when you will upgrade the site site then you must revert this process).
if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__) . ‘/errors/503.php’;
exit;
}
To this
if (file_exists($maintenanceFile) && strpos($_SERVER[‘REQUEST_URI’], ‘/admin/’) === false) {
include_once dirname(__FILE__) . ‘/errors/503.php’;
exit;
}
Please note the the code above is quick and dirty hack and I just check if /admin/ exists in url. If you have another url then you should replace with that.