Can I block people from viewing my site based on their IP address?

Posted on 2009-02-22
Last Modified: 2012-08-14
Is there a way to block certain IP addresses from accessing my site?
Question by:elliottbenzle
    LVL 9

    Expert Comment

    by:Ken Fayal
    Are you asking if you can do this from code or from the web server itself?
    LVL 15

    Expert Comment

    Add the public IP address to your firewall.
    LVL 10

    Expert Comment

    by:Andrew Doades
    simple, add this line to your .htacces file

    deny from

    of course add your own ip address
    LVL 8

    Accepted Solution

    To block certain ip address from accessing your website, just create a file with name .htaccess at your root directory with the content below:-

        order allow,deny
        deny from
        allow from all

    If you want to block multiple ip address using .htaccess simply add one ip address per line as below:-

        order allow,deny
        deny from
        deny from
        deny from
        allow from all

    You can even block a network range ip using .htaccess:-

        order allow,deny
        deny from 129.0.0
        allow from all

    to use htacces the server must be running apache

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Shoutout to Emily Plummer ( for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now