Forum Discussion

OCC_Ops_68605's avatar
OCC_Ops_68605
Icon for Nimbostratus rankNimbostratus
Dec 06, 2013

HTTPS to HTTPS redirect

I need to redirect several https domains to one https main domain, the irule for http to https is working very good, but the same irule with https to https it does not working. Any ideas??

 

11 Replies

  • Need more information please!! What does the iRule look like? And the HTTPS virtual config?

     

    • OCC_Ops_68605's avatar
      OCC_Ops_68605
      Icon for Nimbostratus rankNimbostratus
      This is the iRule: when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "domain1.com" - "domain2.com" - "www.domain1.com" - "www.domain2.com" { HTTP::respond 301 Location "https://www.mymainsite.com" } } } It´s the same iRule for HTTP virtual server.
    • Try putting * after each switch arm clause - just in case you have say :443 appended to the end
    • Add 'return' after HTTP::respond (best practise inncase you have other iRule statements after the switch)
    • Add logging statements in

    Updated iRule;-

    when HTTP_REQUEST {
        log local0. "[HTTP::host] on port [TCP::local_port]"
        switch -glob [string tolower [HTTP::host]] {
            "domain1.com*" -
            "domain2.com*" -
            "www.domain1.com*" -
            "www.domain2.com*"  {
                log local0.  "redirecting"
                HTTP::respond 301 Location "https://www.mymainsite.com"  
                return     
            }
        }
    }
    
    • OCC_Ops_68605's avatar
      OCC_Ops_68605
      Icon for Nimbostratus rankNimbostratus
      Thanks for your help, with this changes the iRule is working now.
    • IheartF5_45022's avatar
      IheartF5_45022
      Icon for Nacreous rankNacreous
      Make suer you take the logging statements out before you go into prod!!
    • OCC_Ops_68605's avatar
      OCC_Ops_68605
      Icon for Nimbostratus rankNimbostratus
      Hi, Do you know How Can I get the params before redirect?? Example: https://www.domain1.com/search_engine/search1 to https://www.mainsite.com/search_engine/search1
  • Not sure what you mean by 'params' but for a stab in the dark do you mean you want to redirect to the same path the request came in on? If so you would use [HTTP::path]

    HTTP::respond 301 Location "https://www.mymainsite.com[HTTP::path]"