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

htaccess block keywords

Discussion in 'Black Hat SEO' started by larsjensen10, May 24, 2013.

Tags:
  1. larsjensen10

    larsjensen10 Newbie

    Joined:
    Sep 24, 2008
    Messages:
    28
    Likes Received:
    0
    How can I use htaccess to block users from entering my site if they have used certain keywords in search engines?
     
  2. Endire

    Endire Elite Member Premium Member

    Joined:
    Mar 27, 2012
    Messages:
    1,756
    Likes Received:
    1,061
    Gender:
    Male
    Larshensen,

    While you can block people using .htaccess based on their IP address, I?m not sure how you would incorporate that with keywords. Alternatively, you could redirect them to a page where they couldn?t get access to your site using JavaScript and Google?s parameters from the URL in its index.

    The code might look something like this to match the Google gi

    if (document.referrer.match(/google\.com/gi) && document.referrer.match(/cd/gi)) {
    var myString = document.referrer;
    var r = myString.match(/cd=(.*?)&/);
    var kw = myString.match(/q=(.*?)&/);
    }

    Then you could redirect them to another page on your domain with no navigation and saying something that would get them to avoid visiting your site. For example a page that says ?this site is down? or ?this site no longer exists? or whatever.

    Hope that helps,

    Shawn
     
  3. jascoken

    jascoken Senior Member

    Joined:
    Nov 1, 2010
    Messages:
    1,135
    Likes Received:
    751
    Gender:
    Male
    Occupation:
    IT/Web Systems & Development...
    Location:
    Sussex:UK
    This is one of the more advanced principles in cloaking/redirects; serving different and usually relevant content to a user based on who they are (search engine spider or user), geo-location, what searches they're doing, and where they clicked from...

    ...but it's FAR more complex than .htaccess statements. You'll need a complete redirect engine with lookups and database access. Check out Fantomaster Shadowmaker for an idea.

    But the route can be quite Black-hat; depending on your configuration and network of sites. If its a single money-site, then anything like this has the potential for Google seeing varying/duplicate results; so tread carefully.
     
    Last edited: May 24, 2013
  4. proweb

    proweb Regular Member

    Joined:
    Feb 24, 2011
    Messages:
    291
    Likes Received:
    144
    Kind of an interesting question...

    Anyway, you can't. Google doesn't pass the keyword variable if the person is logged into their Google account (gmail, youtube, etc.). So you would only be able to get the keyword data from people who were not logged into Google or people who were using other search engines.

    If you did want to redirect the 30-60% of people not logged into Google, I would use a PHP script that's called before the page loads. I'm sure there's a way to do it with .htaccess, but I only know the basics and I'm more advanced with PHP.