X

    Get a Quote

    How To Block IP Address Using .htaccess File

    821 views
    Amit Shukla

    Follow this post for WordPress or any other website using other cms or framework, by editing your .htaccess file. If you are not familiar with the .htaccess file, you can read about it or get in touch with your hosting company.
    If you are getting Spam comments and other spamming activities by some location or from some person at a particular IP address, then you can easily block access to your site by creating a .htaccess file with the following mentioned code in it.

    How To deny IP access to your Website using .htaccess File:

    First, find the IP address of that visitor.

    There are two methods for this:

    -If that visitor already commented in your blog, then you can find that person’s IP address easily from your WP dashboard.
    -Use StatCounter for searching the IP addresses.

    Create a .htaccess file and write the below code in it.

    < Limit GET POST PUT>
    order allow,deny
    allow from all
    deny from 123.298.88.342
    < /Limit>

    Here is 123.298.88.342 is the IP address of the person you want to block. You can replace this with your site visitor’s IP address. You can allow Visitors From Specific IP Address Using .htaccess By this code in your .htaccess file, you can easily block access to your website from every IP address except the IP addresses you specified in the code. It is used mainly when your website is under construction and you don’t want your visitors to see the website until it is complete or even search engine indexing problems.

    < Limit GET POST PUT>
    order deny,allow
    deny from all
    allow from 123.298.88.342
    < /Limit>

    Please note that every IP address should be placed on a new line.

    < Limit GET POST PUT>
    order deny,allow
    deny from all
    allow from 123.298.88.342
    allow from 345.76.321.98
    < /Limit>

    Replace the given IP address with your visitor’s IP address.

    Avatar for Amit
    The Author
    Amit Shukla
    Director of NBT
    Amit Shukla is the Director of Next Big Technology, a leading IT consulting company. With a profound passion for staying updated on the latest trends and technologies across various domains, Amit is a dedicated entrepreneur in the IT sector. He takes it upon himself to enlighten his audience with the most current market trends and innovations. His commitment to keeping the industry informed is a testament to his role as a visionary leader in the world of technology.