InMotion Hosting Support Center

When working on your website, you may want to prevent any visitor from accessing your site except you. This can be done by creating a 302 temporary redirect in your .htaccess file to a construction page. By creating a redirect for any IP address except your own in your .htaccess, you can prevent visitors from accessing your site while you update it. This tutorial will explain how to create a redirect for all IP addresses, except your IP, to a construction page on your server.

Important! You will need to create a page in your public_html called "construction.html". For information on how to create a page in your public_html see our article on Creating an Under Construction or Coming Soon page.

Steps to allow only one IP access

  1. First, you will need to obtain your IP address. Visit the following link to obtain your IP.

  2. Next, Login into your cPanel
  3. Go to the File Manager. Select the public_html web root.

    Important! Make sure you have the show hidden files box checked.

    Click Go.

  4. Edit the .htaccess file with the code editor.
  5. Code view of htaccess redirectPaste the following code at the top of the .htaccess file.

    NOTE! The following code is for IP (The code looks like !^123\.45\.67\.89$). You will want to change the code to your IP.

    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REMOTE_ADDR} !^123\.45\.67\.89$
    RewriteCond %{REQUEST_URI} !construction\.html
    RewriteRule ^(.*)$ /construction.html [R=302,L]

    Save the file.

    Important! If you are pointing to a subdomain you will need to place RewriteEngine Off code in the .htaccess of the subdomains directory.

    Now when your site is visited, any visitor that is not from will be redirected to the construction.php.

    Important! If you cannot access your website after a certain amount of time, its possible your IP address changed at your local connection. This is common with dynamic IP addresses. You can get your IP again and edit the .htaccess to reflect your new IP address to restore you access to your web site.

Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

n/a Points
2015-07-28 2:44 pm

Will this work with a prestashop install on the main directory and a "coming soon" page on a subdirectory?  I'd like to install prestashop very soon but would rather not have to install it locally, configure it, then upload to the server.  

10,077 Points
2015-07-28 11:04 pm
Hello Woodjeweler,

This should work the same, just put the correct page in on the part below:

RewriteRule ^(.*)$ /subfolder/construction.html [R=302,L]

Best Regards,
TJ Edens
n/a Points
2014-06-20 3:54 am

Not showing images for me... :)

Must replace line 4 with: 

RewriteCond %{REQUEST_URI} !(\.(gif|jpg|css)$|^/under-construction\.html$)

thank you. 

n/a Points
2015-08-27 6:35 am

You sir are a gentleman and a scholar! Thanks!

n/a Points
2015-11-24 5:53 pm

even better:

replace it with RewriteCond %{REQUEST_FILENAME} !-f

doesn't rewrite ANY files

n/a Points
2014-06-10 3:48 am

Thanks. It works fine

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

6 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!