Forum Discussion

ha_34906's avatar
Icon for Altostratus rankAltostratus
Nov 10, 2011

change url via iRule

simple irule question, I been looking for an answer and cant find it so sorry if this was answered already.



I need an iRule that can repalce part of a url with another. Meaning if the reqeust comes for "" I would like to change the user's address bar to "" or whatever the user had requested. That means the only part I like to change is between // and nothing after that. So if the request for for a long url such as "" then I like to preserve the "/mysite/test/whatever" path and just replace the domain part.



Let me know if I've explained this and if this can be done via an iRule. Very much apprecaite your help in advance!




2 Replies

  • e.g.

    [root@ve1023:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       ip protocol tcp
       rules myrule
       profiles {
          http {}
          tcp {}
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            if {[HTTP::host] equals ""} {
                    HTTP::redirect "[HTTP::uri]"
    [root@ve1023:Active] config  curl -IL
    HTTP/1.0 302 Found
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    HTTP/1.1 404 Not Found
    Date: Fri, 11 Nov 2011 00:05:15 GMT
    Server: Apache/2.2.3 (CentOS)
    Connection: close
    Content-Type: text/html; charset=iso-8859-1
  • Sorry for late reply nitass. Thank you very much worked like a charm!



    happy holiday :)