Forum Discussion
Anish_Srivastav
Nimbostratus
Mar 02, 2010URL host rewrite based on URI
Hello guys
I was browsing through the forum and could not come across a similar situation that I am facing. We have a website with following links:
http://www.xyz...
hoolio
Cirrostratus
Mar 02, 2010So maybe something like this?
when HTTP_REQUEST {
Check if the subdomain starts with www. or is null
if {[string tolower [HTTP::host]] starts_with "www." or [HTTP::host] eq ""}{
Exit this event in this rule
return
}
log local0. "Host didn't start with www: [HTTP::host]"
Save the first directory in the HTTP path, set to lower case
set first_dir [string tolower [getfield [HTTP::path] "/" 2]]
Check if the first directory matches some pattern like "product"
if {not ($first_dir starts_with "product")}{
Exit this event in this rule
return
}
log local0. "\$first_dir, $first_dir, matched the pattern check"
Check if the first directory in the path is not the same as the subdomain
if {$first_dir ne [getfield [string tolower [HTTP::host]] "." 1]}{
log local0. "Redirecting request to $first_dir.xyz.com"
HTTP::redirect "$first_dir.xyz.com"
}
}
}
Aaron
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
