close the website and open it only for a specific IP

close the website and open it only for a specific IP

39
close the website and open it only for a specific IP

Sometimes, it becomes necessary to restrict access to a website, either for maintenance purposes or other specific reasons. However, there may still be a need to allow access to a single user or a specific IP address. In this guide, I will explain how to close the website to all users while granting access to only one IP address. This approach ensures the site remains secure and restricted during maintenance or troubleshooting while still allowing essential access for authorized personnel.

Step-by-Step Guide: Restricting Website Access to a Specific IP Address

First, Obtain Your IP Address
To start, you’ll need your IP address. [Click here for a guide on finding your IP address].

Access the Cpanel and File Manager
Once you have your IP, log in to your Cpanel and navigate to the File Manager.

close the website and open it only for a specific IP

Locate the Public Directory
Go to the public_html or htdocs folder, depending on whether you’re using a paid or free hosting service. Open the .htaccess file within this folder.

Add the Restriction Code
In the .htaccess file, add the following code to deny access to all users except for the specified IP:

Order Deny,Allow
deny from all
allow from 196.12.12.12
  1. Make sure to replace 196.12.12.12 with your actual IP address.
  2. Save the Changes
    Once you’ve added the code, click Save.
close the website and open it only for a specific IP
  1. Important Note
    If you restart or reset your router, your IP address may change. Be sure to check and update the IP address in the .htaccess file if this occurs to maintain access to the site.

Best of luck, and happy website maintenance!

Motasem Hanani
WRITTEN BY

Motasem Hanani

مطور مواقع، مصمم، ممنتج وكاتب محتوى. اسعى الى تغذية المحتوى العربي التطويري والثقافي في كل ما هو حصري ومفيد بعيداً عن النقل العشوائي والبرامج القديمه التالفة.