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  ...
  • Enes_Afsin_Al's avatar
    Jan 02, 2020

    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]"
    	}
    }