Forum Discussion

sbadea_81872's avatar
sbadea_81872
Icon for Nimbostratus rankNimbostratus
Apr 03, 2013

iRule and robots.txt

Hi all,

 

I have an irule that redirects HTTP to HTTPS and adds www (see below). Is it possible to skip enforcing SSL to a page that looks like this http://www.mycompany.com/robots.txt

 

when HTTP_REQUEST

 

{ if { [HTTP::host] eq "mycompany.com" } { HTTP::redirect "https://www.mycompany.com" }

 

elseif { [HTTP::host] eq "www.mycompany.com" } { HTTP::redirect "https://www.mycompany.com" } }

 

Thank you.

 

 

3 Replies

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

     

    when HTTP_REQUEST {

     

     

    if { ([HTTP::host] equals "mycompany.com") && ( not ([HTTP::path] starts_with "/robots.txt")) } {

     

     

    HTTP::redirect "https://www.mycompany.com"

     

     

    } elseif {

     

     

    ([HTTP::host] equals "www.mycompany.com") && ( not ([HTTP::path] starts_with "/robots.txt")) } {

     

     

    HTTP::redirect "https://www.mycompany.com"

     

     

    }

     

     

    }

     

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    For readability and brevity this might be better:

     

     

    when HTTP_REQUEST {

     

     

    if { not ([HTTP::path] starts_with "/robots.txt") } {

     

     

    if { ([HTTP::host] equals "mycompany.com") } {

     

     

    HTTP::redirect "https://www.mycompany.com"

     

     

    } elseif {

     

     

    ([HTTP::host] equals "www.mycompany.com") } {

     

     

    HTTP::redirect "https://www.mycompany.com"

     

     

    }

     

     

    }

     

     

    }