Forum Discussion

Eugene_Chupkin_'s avatar
Eugene_Chupkin_
Icon for Nimbostratus rankNimbostratus
Feb 25, 2008

iRule to serve up two different robots.txt files for http and https.

 

My secure and non secure content are in the same DocumentRoot as is pretty standard in many cases. I now have the need to serve up a different robots.txt for anyone who initiates a connection using https. Can someone suggest the best way to approach this problem.

 

 

Thanks!

1 Reply

  • Hi,

    If you created a robots_https.txt on the webserver(s), you could use an iRule to rewrite the request on the HTTPS virtual server. Or you could respond directly from the rule with the HTTPS version of the robots.txt file and leave the web server to answer for the HTTP version.

    HTTP::uri (Click here)

    HTTP::respond (Click here)

    Here is an example of the first option:

    
     Use this rule to rewrite the HTTPS requests to robots.txt to robots_https.txt
    when HTTP_REQUEST {
        Check if the request is to /robots.txt
       if {[HTTP::path eq "/robots.txt"}{
           Rewrite the request to /robots_https.txt
          HTTP::path /robots_https.txt
       }
    }

    Aaron