Forum Discussion

toofat's avatar
toofat
Icon for Nimbostratus rankNimbostratus
Jan 02, 2020
Solved

redirect based on user input urls

I want to redirect all *.web1.com address to *.web2.com

for example,

when user input abc.web1.com,it will be redirect to abc.web2.com

input abcdef.web1.com will be redirect to abcdef.web2.com

 

and the number of addresses is over 300...

 

please give me some suggestions

 

thanks :)

 

  • Hi toofat,

    Can you try this iRule?

    when HTTP_REQUEST {
    	if { [HTTP::host] ends_with "web1.com" } {
    		set newHost [string map {"web1.com" "web2.com"} [HTTP::host]]
    		HTTP::redirect "https://$newHost[HTTP::uri]"
    	}
    }

2 Replies

  • Hi toofat,

    Can you try this iRule?

    when HTTP_REQUEST {
    	if { [HTTP::host] ends_with "web1.com" } {
    		set newHost [string map {"web1.com" "web2.com"} [HTTP::host]]
    		HTTP::redirect "https://$newHost[HTTP::uri]"
    	}
    }
    • toofat's avatar
      toofat
      Icon for Nimbostratus rankNimbostratus

      Thank you very very much~~

      this is exactly what I want

      Thanky you :)