There will be times when you want to prevent visitors from accessing your online store. Perhaps you’re making adjustments to the site or adjusting a few settings before going live after importing a product list. You will need to change the system to go into «maintenance mode.»
Maintenance mode allows you to make those programming changes or additions without visitors accessing the information or committing sales when your website isn’t ready. This is especially useful if you have sections of coding open that could lead to a compromised website for hackers.
Unfortunately, Magento doesn’t have an easy way to take the site offline. Unless you buy an extension that includes this ability, you have to set maintenance mode manually. If you plan on making a lot of changes in the future, spending the money to install the module for maintenance mode would be a good investment.
Today, I’m going to show you how to enable maintenance mode in Magento using cPanel’s File Manager. Don’t worry, it’s only going to require a few copy and pastes from you to set this up.
Accessing Your Computer’s IP Address
In order to set maintenance mode for everyone except yourself, you need to find out your Internet connection’s IP address. This is relatively easy, especially if you’re used to using Google.
Go to Google’s website and type in «My IP Address» in the search bar.
This is your public IP address that will be detected by Magento. Should your address change, you will need the new address for the next steps.
Creating the Maintenance Mode File
In order for maintenance mode to activate, you need a file placed in the «var» directory of Magento.
From cPanel, click on the tool for File Manager.
Access your root directory for Magento. If you only have the eCommerce software installed, it will be located in the «public_html» directory.
Access the «var» folder in the directory to open its contents. You can do this by double clicking the folder icon.
Click the «+ File» button on the top left of the File Manager.
In the New File Name, enter .maintenance.flag and click «Create New File.»
Right click the new file and select «Edit» from the drop down list. Mac users will press CMD and click. You can also select the file and click «Edit» from the top tool bar.
You will now see a blank screen. On the first line of page, enter in the following code:
[ht_message mstyle=»info» title=»» show_icon=»» id=»» class=»» style=»» ]magento maintenance:enable —ip=192.168.0.1[/ht_message]
NOTE: Change the «192.168.0.1» to your Internet IP address you got from the Google search page from above.
Once you’ve entered the code, click the button to «Save Changes.»
What if you want to disable maintenance mode? Simply change «enable» to «disable» in the above within the .maintenance.flag file. You can also simply delete the file, but you may find it useful to leave active should you need to put the site in maintenance mode again in the future.
After all is said and done, it may be far easier to use a module specifically for enabling and disabling maintenance mode in Magento. At any rate, this is just one method to secure your Magento hosted website while making adjustments. This is better than the alternative of people and search engine bots stumbling across a broken site while you spend time fixing it.