Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED Restricting IP access to a specific website page

Discussion in 'Security' started by chanklish, Oct 5, 2017.

  1. chanklish

    chanklish Active Member

    Joined:
    May 22, 2015
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    kinshasa
    cPanel Access Level:
    Root Administrator
    hello awesome people of cpanel
    i am looking to restrict access to a specific page in my website to a number of ip addresses
    i already looked into blocking ip option in cpanel or in htaccess but this will block the entire website - i just want to restrict a single page per example the CMS login page
    is this doable on whm/cpanel ?!
    thank you
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,427
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  3. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,370
    Likes Received:
    5
    Trophy Points:
    168
    cPanel Access Level:
    Root Administrator
  4. chanklish

    chanklish Active Member

    Joined:
    May 22, 2015
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    kinshasa
    cPanel Access Level:
    Root Administrator
    no a CMS for a regular website not wordpress .. i want to IP restrict it
     
  5. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    335
    Likes Received:
    95
    Trophy Points:
    28
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    In your htaccess file, you could try the following format:
    Code:
       <Files file.ext>
           Order deny,allow
           Deny from all
           Allow from 127.0.0.1
           Allow from 127.0.0.2
       </Files>
    where file.ext is the file you want to restrict the access to, and 127.0.0.1, 127.0.0.2 etc are the IPs you want to allow access to that file (add as many as you need)

    If the file you are trying to protect is in a sub-folder, you might need to create an additional htaccess file with the above code in the folder that contains the file
     
    chanklish likes this.
  6. chanklish

    chanklish Active Member

    Joined:
    May 22, 2015
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    kinshasa
    cPanel Access Level:
    Root Administrator
    the page im looking to restrict is something like this : example.com/admin/login.php so the page is login.php ..
    how do i know if i need another htaccess ? this login.php is inside /public_html/admin and the htaccess is in public_html
     
    #6 chanklish, Oct 6, 2017
    Last edited by a moderator: Oct 6, 2017
  7. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    335
    Likes Received:
    95
    Trophy Points:
    28
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Add a new .htaccess file into the folder /admin with the code above, replacing the 'file.ext' with login.php and changing the IPs as required
     
    chanklish likes this.
  8. chanklish

    chanklish Active Member

    Joined:
    May 22, 2015
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    kinshasa
    cPanel Access Level:
    Root Administrator
    worked perfectly ! thank you
     
  9. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    335
    Likes Received:
    95
    Trophy Points:
    28
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    You are very welcome.
     
Loading...

Share This Page