Forum Discussion

Sean_O_Brien_65's avatar
Sean_O_Brien_65
Icon for Nimbostratus rankNimbostratus
Feb 09, 2010

url forward for http and https based on request

need an irule to forward to different url based on how the request came in...

 

 

example:

 

 

when HTTP_REQUEST {

 

if {[HTTP::host] equals "dev.domain1.com"}{

 

HTTP::redirect "http://dev-domain1.domain2.com"

 

}

 

}

 

 

 

I need to add to this another domain url that looks the same but is 'qa' instead of 'dev'.

 

 

also would like this single iRule to handle http -> https at the same time, if possible... It sure seems like that shouldn't be an issue.

 

 

I tried doing this with an if / else, but I guess I'm having issue getting the syntax correct, but it seems like that would work.

 

 

Given our dns, only these two url's would ever go to this VS address.

 

 

Thanks!
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Sean,

    Here is an example:

     
     when HTTP_REQUEST { 
      
         Check the requested host header (set to lowercase) 
        switch [string tolower [HTTP::host]] { 
           "dev.domain1.com" { 
              HTTP::redirect "http://dev-domain1.domain2.com" 
           } 
           "qa.domain1.com" { 
              HTTP::redirect "http://qa-domain1.domain2.com" 
           } 
           default { 
               Take some default action?  
               Requests using the IP address would hit here 
           } 
        } 
     }  
     

    Aaron
  • Awesome, thanks for the help!

     

     

    I'm trying this now... just waiting for my DNS to update.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    You could test this by adding host file entries on your client (/etc/hosts for *nix or c:\windows\system32\drivers\etc\hosts on Windows).

     

     

    Aaron
  • Posted By hoolio on 02/10/2010 8:32 AM

     

     

    You could test this by adding host file entries on your client (/etc/hosts for *nix or c:\windows\system32\drivers\etc\hosts on Windows).

     

     

    Aaron

     

     

     

    Yes, understood. I'm remoted in via VPN and I have other folks looking at this as well so I did test locally, but wanted others to use the updated DNS.

     

     

    Also, I just got it working, just wanted to let you know (and others if following) that I had an issue, but realized I had an old wildcard cert loaded on the https VS so I was getting prompted before the redirect when trying https:// but the http:// worked so I knew it was a different issue.

     

     

    Thanks again for the help. I love these iRules but I can never seem to get them first try!