Forum Discussion

Shay_Ben-David1's avatar
Shay_Ben-David1
Icon for Nimbostratus rankNimbostratus
Mar 13, 2007

Referer check

Hi, i used this irule from the wiki list:

 

when HTTP_REQUEST {

 

set refer_host [string tolower [URI::host [HTTP::header Referer]]]

 

if { ( [matchclass [HTTP::uri] ends_with $::images] ) and

 

( not [matchclass $refer_host starts_with $::allowed_referers] ) } {

 

log "hotlink detected from host: $refer_host"

 

HTTP::redirect "https://mysite.com"

 

HTTP::respond 301 "Location" "http://[HTTP::host]/Online/images/logo-account.gif"

 

}

 

}

 

 

it seems to work fine, but i need help on this irule to check the referer only on the main page, like aspx or jsp files, does anyone have an idea how to perform this with irule ?

 

2 Replies

  • You could put .aspx and .jsp into the images data group. That way the first matchclass would only pass if they are at the end of the uri.

     

     

    -Joe
  • i did put the .aspx and .jsp into the images data group, but still the redirect is not perform based on the missing referer in the jsp/aspx files ?

     

    is there a way to force the redirect based on the aspx/jsp files only ?

     

    10nx