1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Combining 301's and anti-bot code in .htaccess

Discussion in 'Apache' started by Teddyd, Aug 20, 2006.

  1. #1
    I have a simple 301 redirection in the .htaccess of most of my sites (see code below).

    On one OTHER site that does not include any 301, I'm also using an anti-scraper routine, banning the IPs that do not "behave well". In .htaccess as well (see code below).

    However, I was stuck today when trying to implement the 2 options above at the same time, on one same site, with one single .htaccess file. I thought I could just combine the code of these two routines but it creates a pretty bad error (cannot access any page).

    Is there anything special I should add like an if/then condition? I honestly thought I could just combine these 12 lines of code to get the functionality I wanted: 301 redirection to www.example.com + anti-scraper trick.

    It can probably be solved very easily but I've tried so many times that I'm getting lost...

    -T
    A) 301:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*) http://www.example.com/$1 [L,R=301]

    B) anti-scraper:
    SetEnvIf Remote_Addr ^23\.128\.115\.16$ getout # Fri May 19 10:44:45
    ((((note: add'l banned IPs go here and are added by a perl script when bots are detected))))
    SetEnvIf Request_URI "^(/403.*\.html¦/robots\.txt)$" allowsome
    <Files *>
    order deny,allow
    deny from env=getout
    allow from env=allowsome
    </Files>
     
    Teddyd, Aug 20, 2006 IP