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.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Support Center Login

Social Media Login

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
n/a Points
2014-06-10 3:48 am

Thanks. It works fine

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. 

Post a Comment

Email Address:
Phone Number:

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

3 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: support@InMotionHosting.com
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!