Forum Discussion
ukitsysadmin_95
Nimbostratus
Nov 10, 2009replace http::host headers
Is it possible to do the following
when HTTP_REQUEST {
if { [HTTP::host] starts_with "preview.www."} {
I want to redirect to
HTTP::redirect "http://preview2.www."same domain name"
but I keep getting
preview2.www.preview.www.abc.com
We have hundreds/thousands of domain names and growing, example
abc.com
def.com
ghi.com
because the growing number of domains
I want the irule just to replace, preview.www."domain name" with preview2.www."same domain name"
so no matter what domain name I type preview.www.abc.co.uk or com or be etc, etc it will redirect to preview2.www.abc.co.uk or com or be etc, etc
type:
preview.www."any domain name" redirect to preview2.www."same domain name"
Hope this make sense ?
- hoolio
Cirrostratus
You can use the domain command to parse the domain from the HTTP::host value:when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New [HTTP::method] request to [HTTP::host][HTTP::uri]" if { [string tolower [HTTP::host]] starts_with "preview.www."} { log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to http://preview2.www.[domain [HTTP::host] 2]" HTTP::redirect "http://preview2.www.[domain [HTTP::host] 2]" } }
- hoolio
Cirrostratus
Actually, the domain command won't work for this scenario if you need to support example.com and example.co.uk...when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New [HTTP::method] request to [HTTP::host][HTTP::uri]" if { [string tolower [HTTP::host]] starts_with "preview.www."} { log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to preview2.www.[getfield [string tolower [HTTP::host]] preview.www. 2]" HTTP::redirect "http://preview2.www.[getfield [string tolower [HTTP::host]] preview.www. 2]" } }
- ukitsysadmin_95
Nimbostratus
Thats excellent thank you,
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects