[Tutorial][.htaccess] Allowing Access to a File from Certain IPs

reloadmydeagle Feb 13, 2015

  1. reloadmydeagle

    reloadmydeagle I LoVe GoldZ Lifetime Gold XPG Retired Staff
    135/188

    Joined:
    Oct 30, 2013
    Messages:
    1,608
    Likes Received:
    656
    Trophy Points:
    135
    Gender:
    Male
    Location:
    Texas
    Console:
    Xbox One
    This is a cool little trick I discovered where you can take any file on your server and lock it to where only IPs you specify can access it. All others get a 403 forbidden error. This is done using the .htaccess file on your sever root, and is perfect for securing admin panels.

    Add this code to your .htaccess:


    <Files FILE-YOU-WANT-TO-PROTECT.php>
    Order Deny,Allow
    Deny from all
    Allow from 77.77.777.77 <--Your IP
    </Files>


    You can add multiple IPs by adding a space after the 1st one like so:

    Allow from 77.77.777.77 55.55.555.55 <--Your Multiple IPs

    You can make it allow a specific IP range (good for dynamic IPs) by using a slash like so:

    Allow from 77.77.777.0/777 <--Your IP Range at the end

    Enjoy! ;)
     

Share This Page

Close