Forum Discussion

Adnankhan's avatar
Adnankhan
Icon for Nimbostratus rankNimbostratus
Dec 09, 2020

Url redirect

Hello Everyone,

 

I would like to do the following, Any help would be appreciated.

 

I have 3 URLs abc.org, def.org and ghi.org they all point to the same vip, i would like, when user go to these URLs, URL should change to xyz.com(new vip with the same ip).

 

Please let me who i can achieve this. thanks in advance.

 

 

  • Hi Adnankhan,

    when HTTP_REQUEST {
    	switch [HTTP::host] {
    		"abc.org" -
    		"def.org" -
    		"ghi.org" {
    			HTTP::respond 301 Location "http://xyz.com[HTTP::uri]"
    			return
    		}
    	}
    }
  • Hi eaa,

     

    i have tried this

    when HTTP_REQUEST {

    switch [HTTP::host] {

    "abc.org" {

    HTTP::respond 301 Location "http://xyz.com[HTTP::uri]"

    return

    }

    }

    }

     

    but it doesn't change the URL.

  • Hi Adnankhan,

    I guess your test client's traffic isn't pass over F5.

    Can you review the logs and tcpdump?

    when HTTP_REQUEST {
    	log local0. "vslog1 | CIP: [IP::client_addr] | Host: [HTTP::host]"
    	switch [HTTP::host] {
    		"abc.org" {
    			log local0. "vslog2 | CIP: [IP::client_addr] | Host: [HTTP::host]"
    			HTTP::respond 301 Location "http://xyz.com[HTTP::uri]"
    			return
    		}
    	}
    }

    logs:

    tail -f /var/log/ltm | grep vslog

    tcpdump:

    tcpdump -ni 0.0 host <virtualserverIP> and host <clientIP>