Forum Discussion
Greg_Bishop_104
Jun 27, 2011Nimbostratus
redirect subdomain to append to uri
Hey guys, I've done a little bit with iRules but not very much. What I'm looking for is to redirect a large number of subdomains such as the following:
greg.domain.com --> www.domain.com/sit...
nitass
Mar 01, 2013Employee
e.g.
[root@ve10:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.19.252:80
ip protocol 6
rules myrule
profiles {
http {}
tcp {}
}
}
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
set subdomain [string map {"www." "" ".domain.com" "" "domain.com" ""} [string tolower [HTTP::host]]]
if { $subdomain ne "" } {
HTTP::redirect "http://www.domain.com/site/$subdomain"
}
}
}
www.domain.com
[root@centos251 ~] curl -I http://172.28.19.252 -H "Host: www.domain.com"
HTTP/1.1 200 OK
Date: Sat, 02 Mar 2013 00:22:03 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Sat, 27 Oct 2012 03:22:35 GMT
ETag: "4183f3-59-f28f94c0"
Accept-Ranges: bytes
Content-Length: 89
Content-Type: text/html; charset=UTF-8
abc.domain.com
[root@centos251 ~] curl -I http://172.28.19.252 -H "Host: abc.domain.com"
HTTP/1.0 302 Found
Location: http://www.domain.com/site/abc
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
www.abc.domain.com
[root@centos251 ~] curl -I http://172.28.19.252 -H "Host: www.abc.domain.com"
HTTP/1.0 302 Found
Location: http://www.domain.com/site/abc
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
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