Deny by both IP and browser

Discussion in 'Apache' started by emmet, Jul 19, 2010.

  1. #1
    I want to deny access in htaccess to a particular person. I have his regular IP range and his browser. I.e. I would like to deny access to persons coming from IP range XX.XX AND using Safari 4.0

    Is this possible? How can I do it?
     
    emmet, Jul 19, 2010 IP
  2. EvanP

    EvanP Banned

    Messages:
    1,731
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think you can deny a browser, however I may be wrong.
     
    EvanP, Jul 19, 2010 IP
  3. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #3
    a browser is a "user agent" and thus can be access-denied
    however you also may deny all others having same browser

    to deny user agents is common to block spambots, etc because they typically use very uncommon precise user agents OTHER than typical surfers

    an entry in htaccess for a single browser could look something like

    Order Allow,deny
    Allow from all
    deny from user-agent "your browser here"

    for details see
    http://httpd.apache.org/docs/2.2/howto/access.html
     
    hans, Jul 21, 2010 IP
  4. travelguides

    travelguides Peon

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, you can deny access based on browser types. Here's an example:

    SetEnvIf User-Agent ^Safari pass_through
    <Directory /docroot>
    Order Deny,Allow
    Deny from all
    Allow from env=pass_through
    </Directory>

    This will block all browsers other than Safari. Bear in mind that this will block everyone using the browser you're trying to block from accessing the site.

    Here's the code to block an IP:

    order allow,deny
    deny from 255.0.0.0
    deny from 123.45.6.
    allow from all
     
    travelguides, Jul 25, 2010 IP