Preventing direct access using htaccess

Discussion in 'Apache' started by Mr.Bill, Apr 8, 2009.

  1. #1
    Right now if you use a query in the url bar like this you can get the results without using the captcha on my site.

    http://example.com/results.php?s=google.com&q=1

    I need to make it so that this can only be ran from my site. So somehow if the page header is not from my site they would get sent to the home page of the site

    Something like this script does but I dont know how to make match my sites link pattern

    RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com(/)?.*$ [NC]
    RewriteRule .*\page.php$ http://www.example.com [R,NC]
     
    Mr.Bill, Apr 8, 2009 IP
  2. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #2
    but to make your above solution to work properly
    you may have to exclude all SE-bots and RSS bots, etc as well
    else those protected pages get lost in index
     
    hans, Apr 13, 2009 IP