1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I block viewing of my site by IP

Discussion in 'Blogging' started by tygrus, Aug 18, 2010.

  1. tygrus

    tygrus Supreme Member

    Joined:
    Mar 28, 2009
    Messages:
    1,237
    Likes Received:
    828
    Occupation:
    Engineer
    Location:
    Canada
    I want to put restriction on viewing of my wordpress site only by IPs I authorize. Everyone else that comes gets a 404. How do I do this?
     
  2. crazyflx

    crazyflx Elite Member

    Joined:
    Nov 9, 2009
    Messages:
    1,676
    Likes Received:
    4,836
    Open up notepad and paste this into it:

    order deny,allow
    allow from IP ADDRESS HERE
    allow from IP ADDRESS HERE
    ETC
    ETC
    ETC
    deny from all

    Save it as .htaccess and upload it to the root folder of your site.

    This will block every IP address that comes to your site, except for the ones you specify. You can also do the opposite, and allow any visitor except for the ones you specify CAN'T visit your site by doing this:

    order allow,deny
    deny from IP ADDRESS HERE
    deny from IP ADDRESS HERE
    ETC
    ETC
    allow from all

    Obviously, remove the "etc" or replace them with IP addresses.

    Since you're using WP, you probably already have an .htaccess file, so you're going to actually want to download that one, open it up and ADD what I pasted above TO IT and then reupload it.
     
    • Thanks Thanks x 2
    Last edited: Aug 18, 2010