1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do you restrict directory access using .htaccess File to Block IP Access

Discussion in 'Security' started by proservers, Apr 17, 2014.

  1. #1
    Using a .htaccess file will grant you greater control over your website, such as safe guarding it from hacking attempts or even keeping out spammers who may frequent your website. A great feature of using a .htaccess file is the ability to populate it with single IP addresses or entire IP ranges, effectively blocking those IP’s from being able to access your server. This article will explain how to implement this via the .htaccess file.

    You will need to log into your Linux server directly using SSH.

    To create the .htaccess file, you need to create a text file with any Linux editor. The file must be called .htaccess and it must exist in the root directory of the website you want to deny access to.

    In the file, there is a specify format you must adhere to. To block both single IP’s and IP ranges, you must include the following;

    order allow,deny – The rule set
    deny from 192.168.1 – IP you want to block
    deny from 24.0.0.0/23 – IP Range you want to block

    Please note to block an IP Range, you must know the subnet.

    You can also specify a deny all and allow rule set as well;

    order deny,allow – The rule set
    deny from all – Deny access from all IP’s.
    Allow from 192.12.4.1 – IP you want to allow.

    An example of a file blocking IP address 1.2.3.4 and a subnet 2.0.x.x is below:




    order allow,deny
    allow from all
    deny from 1.2.3.4
    deny from 2.0.
     
    proservers, Apr 17, 2014 IP
  2. PrimeWebDev

    PrimeWebDev Active Member

    Messages:
    28
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    #2
    Hello,
    Do you know if there is a limit on how many ip addresses or ip ranges that could be added to the .htaccess file? And if the list becomes too long, could this affect the site load time?
    Cheers
    Mike
     
    PrimeWebDev, Mar 5, 2015 IP