Forum Discussion

vvskaladhar_488's avatar
vvskaladhar_488
Icon for Nimbostratus rankNimbostratus
Jan 18, 2015

HTTP::host and if match, redirect by using HTTP::redirect.

HI All, Can some one suggest me an irule

 

which will redirect to www.

 

For example.. if user type test.com it should redirect to www.test.com

 

1 Reply

  • One of your best bets will be to check out a few different pages including the wiki article for HTTP::uri to understand how to modify the URI in an iRule. Also the iRules 101 articles that are a good introduction to iRules in general and how to write them.

    Then, you can look at this iRule and better understand exactly what's going on, or how to modify it in the future to suit any changing needs you may have.

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] equals "example.com" } {
            HTTP::redirect "http://www.example.com[HTTP::uri]"
        }
    }
    

    That being said, another option would be to use a Local Traffic Policy to do the redirect. Here's a devcentral page talking about setting one up.