Forum Discussion

mj16othman's avatar
mj16othman
Icon for Altostratus rankAltostratus
Apr 10, 2022

HTTP Header insert

HI all 

Guys im facing an issue. I have a domain lets say "abc.osm.com" Now currently when the users type in their browser "abc" its automatically  opens the website for them.

I want to create an irule in which once they type in "abc" in their browser, that its automatically inserts "osm.com" inside the header regardless of the full url path. 

Example: 

http://abc/SalesChannel/portal/home.action
http://abc/Portal/backoffice/Home.action

After 

http://abc.osm.com/SalesChannel/portal/home.action
http://abc.osm.com/Portal/backoffice/Home.action

  • Hi mj16othman,

    when HTTP_REQUEST {
    	if { [HTTP::host] equals "abc" } {
    		HTTP::redirect http://abc.osm.com[HTTP::uri]
    		return
    	}
    }

    If you need it for many hostnames:

    when HTTP_REQUEST {
    	switch [HTTP::host] {
    		"abc" -
    		"def" -
    		"xyz" {
    			HTTP::redirect http://[HTTP::host].osm.com[HTTP::uri]
    			return
    		}
    	}
    }
  • Hi mj16othman,

    when HTTP_REQUEST {
    	if { [HTTP::host] equals "abc" } {
    		HTTP::redirect http://abc.osm.com[HTTP::uri]
    		return
    	}
    }

    If you need it for many hostnames:

    when HTTP_REQUEST {
    	switch [HTTP::host] {
    		"abc" -
    		"def" -
    		"xyz" {
    			HTTP::redirect http://[HTTP::host].osm.com[HTTP::uri]
    			return
    		}
    	}
    }