.htaccess “under construction” page

The .htaccess file is an important configuration file for your website that can be customized to do a number of things, such as force your site to use https or redirect to certain pages. One redirect a number of people ask about is an “Under Construction” or “Maintenance” page.

Say you are building a site, and want to keep it behind an “Under Construction” page while you continue to work on it. Now, there are a number of WordPress plugins that can help you with this, but if you’re not using WordPress then they won’t be of any help to you. However, you can create an “Under Construction”, and using the .htaccess file redirect to it.

First thing you’ll need to do is log in to cPanel, and under the Files section, click File Manager.

Next, navigate to the directory of the domain you want to set as “Under Construction”. This can be your primary domain, which will be under public_html, or in this case, the sitepub subdomain.

41%20PM

You will need to make hidden files visible, so up in the top right corner, hit the Settings button.
1

A popup will appear, and you just need to check Show Hidden Files and hit Save.
2

Now, you’ll need to Upload your custom “Under Construction” html file to your site’s directory. You can either do this directly through cPanel, or through FTP.
3

Once the file is uploaded, go ahead and select the .htaccess file and hit Edit.

10%20PM

If the file isn’t there, create it by hitting File in the left hand corner of the menu.
4

If anything is in your .htaccess file, you’ll need to comment it out by adding # (number sign/pound/hash/etc) to the beginning of each line. Then add these lines to the end, replacing construction.html with the name of your file.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/construction.html$
RewriteRule .* /construction.html [L]

Now anytime your site, they should be redirected to the “Under Construction” page. Once you’re done working on your site, just remove, or comment out, the lines and uncomment (by removing the # from) the original lines in the file.