Forum Discussion

Derrick_85757's avatar
Derrick_85757
Icon for Nimbostratus rankNimbostratus
Aug 26, 2008

Webpage redirection

I am a newbie to iRules so pardon my stupidity. I have a client that requested a http to https redirection for a website. I created the http VS and https VS and applied the iRule for redirection. This works just fine. Now the client has come to me and asked me to redirect their old URL's to their new one. For example, they need www.xxyy.com and www.zzyy.com to be redirected to www.yyy.com. Simple redirection would work fine for this, but since I have to redirect http to https in conjunction with changing the URL, and since there are multiple URLs to redirect, I am not sure how to do this. Any advice would be greatly appreciated.

1 Reply

  • Hi there,

    If you want to redirect all requests to the HTTP VIP to an https domain with the original URI, you can use a rule like this:

     
     when HTTP_REQUEST { 
        HTTP::redirect https://newsite.example.com[HTTP::uri] 
     } 
     

    If you want to redirect to different domains based on the requested domain, you could use a switch statement (Click here😞

     
     when HTTP_REQUEST { 
      
         Check the Host header value (set to lower case and using wildcard matching) 
        switch -glob [string tolower [HTTP::host]] { 
      
        "*.example.com" { 
           HTTP::redirect https://newsite.example.com[HTTP::uri] 
        } 
        "*.example2.com" { 
           HTTP::redirect https://[HTTP::host][HTTP::uri] 
        } 
        default { 
           HTTP::redirect https://newsite2.example.com 
        } 
     } 
     

    Aaron