Forum Discussion

Sami_Sheikh_140's avatar
Sami_Sheikh_140
Icon for Nimbostratus rankNimbostratus
Feb 21, 2014

Hostname redirect to Subdirectory URL

Hi,

 

I am looking to create an iRule which would redirect users from: Http://example.com or https://example.com to https://example.com/example1/example.htm.

 

Currenty I have the F5 Virtual appliance 11.4 LTM so I am wondering if this is something that the F5 can handle.

 

Thanks

 

3 Replies

  • Yes you can do it with iRules using HTTP::redirect For https connections, you will need to off load the SSL certificate to F5 so that the F5 can read the decrypted traffic

     

    • Sami_Sheikh_140's avatar
      Sami_Sheikh_140
      Icon for Nimbostratus rankNimbostratus
      I have the SSL certs and all the virtual servers setup. All i need is a redirect from Example.com to example.com/welcome/welcome.htm. How can I achieve that in the irule?
  • e.g.

     config
    
    root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar80
    ltm virtual bar80 {
        destination 172.28.24.10:80
        ip-protocol tcp
        mask 255.255.255.255
        pool foo
        profiles {
            http { }
            tcp { }
        }
        rules {
            myrule
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        vs-index 12
    }
    root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar443
    ltm virtual bar443 {
        destination 172.28.24.10:443
        ip-protocol tcp
        mask 255.255.255.255
        pool foo
        profiles {
            clientssl {
                context clientside
            }
            http { }
            tcp { }
        }
        rules {
            myrule
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        vs-index 13
    }
    root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule myrule
    ltm rule myrule {
        when HTTP_REQUEST {
      if { [HTTP::host] eq "example.com" and [HTTP::uri] eq "/" } {
        HTTP::redirect "https://[HTTP::host]/welcome/welcome.htm"
      }
    }
    }
    
     test
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10/ -H "Host: example.com"
    HTTP/1.0 302 Found
    Location: https://example.com/welcome/welcome.htm
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve11a:Active:In Sync] config  curl -Ik https://172.28.24.10/ -H "Host: example.com"
    HTTP/1.0 302 Found
    Location: https://example.com/welcome/welcome.htm
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0