Uploading a temporary maintenance page

Posted:  May 14th, 2018

 

During migration, maintenance or other times, you may want to suspend access to website(s) within a server.

 

NOTE: This method will only work if the server is online/reachable. It cannot be used for an offline server during a hardware  or a network maintenance.

 

Remember that during a migration the .htaccess page will also be moved and you will need to rename or move it to make your website available again.

 

cPanel

 

Connect to your server via SSH or SFTP (FTP by SSH). Instructions for both are listed below:

 

(If you don't remember your SSH port, contact KEKhost/KEKhosting customer service)

 

SSH Method

 

1) Log into SSH and go to the /home folder

 

cd /home

 

 

2) Use your favorite linux text editor (vi, vim or nano) and create this file :

 

nano .htaccess

 

 

3) Include the following code inside:

 

<Files *>

 

Order Deny,Allow

 

Deny From All

 

# Modify x.x.x.x to allow your IP

 

Allow From x.x.x.x.x

 

</Files>

 

# Modify to show the message you wish on the page

 

ErrorDocument 403 "The site is down temporarily for maintenance. Please come back later."

 

SFTP Method

 

1) Create a new file using a text editor and save it as .htaccess (make sure it is not .htaccess.txt or it will not work).

 

<Files *>

 

Order Deny,Allow

 

Deny From All

 

# Modify x.x.x.x to allow your IP

 

Allow From x.x.x.x.x

 

</Files>

 

# Modify to show the Message you wish on the page

 

ErrorDocument 403 "The site is down temporarily for maintenance. Please come back later."

 

 

2) Log in using your root login and password. You will be inside the /root directory.

 

3) Use the back button of your FTP client to go to the parent directory, then select the /home folder.

 

4) Simply deposit the .htaccess file in that directory and test your website.

 

-- NOTES --

 

You can modify the "Allow From" part with your IP if you wish to keep access to your website. The .htaccess function is to deny access to everyone and displaying the 403 error that you have selected.

 

If you want to do that for one account only, use FTP and log in with the cPanel credentials of the account you want to manage (not root) and upload the in /home username.

 

You can also point the current 403 error to a file (it won't load images)