htaccess to deny all except googlebot to single file and redirect other request 2 hom

Discussion in 'Apache' started by mipa jim, Sep 22, 2009.

  1. #1
    looking to modify htaccess to deny request to view a single file vidmap.xml file from all except googlebot.

    and then redirect all other request to home page.

    here is what I have so far.
    
    RewriteEngine on
    ... ... ... ...
    <Files vidmap.xml>
    order allow,deny
    deny from all
    </Files> 
    
    Code (markup):
    that works just fine for all request but getting it to allow googlebot and redirecting to my home page for denied request.

    I like htaccess but it scares heck out of me to play with it... so thanks for you sharp guys that are willing to help.

    Thanks,
    Jim
     
    mipa jim, Sep 22, 2009 IP
  2. mipa jim

    mipa jim Peon

    Messages:
    261
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ok may have gotten a little further with some help from friend
    
    <Files vidmap.xml>
    order allow,deny
    deny from all
    allow from googlebot.com google.com
    satisfy any
    </Files>
    
    Code (markup):
    google will tell me I have it wrong for them when I get map submitted.

    Now just short how to redirect the failed attempts to site home .. if anyone has time to help out...

    Thanks
     
    mipa jim, Sep 22, 2009 IP
  3. TheOnly92

    TheOnly92 Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't think you can specify user-agent to block in htaccess...
     
    TheOnly92, Sep 23, 2009 IP
  4. mipa jim

    mipa jim Peon

    Messages:
    261
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ouch!!!!


    Ok then wondering about how to redirect users trying to access the h taccess file. I currently have it blocked for all using this
    
    <Files .htaccess>
    order allow,deny
    deny from all
    </Files>
    
    Code (markup):
    Now wondering if can get those people redirected to domain home page?
     
    mipa jim, Sep 23, 2009 IP
  5. TheOnly92

    TheOnly92 Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Why not do them through PHP, will be much easier.
     
    TheOnly92, Sep 28, 2009 IP