Forum Discussion

Michael_-_Harr1's avatar
Michael_-_Harr1
Icon for Nimbostratus rankNimbostratus
May 29, 2014

REDIRECT IRULE need some help

I need help configuring a IRULE to redirect .com traffic to .org wether it is http or https

 

http:\mobilebank.com https:\www.mobilebank.org https:\mobilebank.com https:\www.mobilebank.org

 

3 Replies

  • this is an example for http. for https, just change HTTP::redirect command from http to https.

    e.g.

     config
    
    [root@ve11a:Active:In Sync] config  tmsh list ltm rule qux
    ltm rule qux {
        when HTTP_REQUEST {
      if { [HTTP::host] ends_with ".com" } {
        HTTP::redirect "http://[string map {.com .org} [HTTP::host]][HTTP::uri]"
      }
    }
    }
    
     test
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10/something -H "Host: mobilebank.com"
    HTTP/1.0 302 Found
    Location: http://mobilebank.org/something
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10/something -H "Host: www.mobilebank.com"
    HTTP/1.0 302 Found
    Location: http://www.mobilebank.org/something
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    
  • This should work for you:

    when HTTP_REQUEST {
     if { [string tolower [HTTP::host]] ends_with "mobilebank.com" } {
      HTTP::redirect "https://www.mobilebank.org"
      }
    }
    
  • Keep in mind though that if an HTTPS request arrives for mobilebank.com, you'll need to terminate the SSL in order for these iRules to do any redirection.