Forum Discussion
iRule - Url rewrite and header replace and pool selection not working
I have a scenario where I need to perform a header replace and url rewrite and select a pool.
I have several sites that I need to select a specific pool and they all have to come through the same
virtual server.
When I select a pool the content returned is not complete. The web page is missing formatting and content.
If I define a default pool that would be used for the specific site the content returned is complete for that site
but still missing content for the other sites not using a default pool.
I have tried a /32 oneconnet profile and that made no difference.
Below is my irule
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"mywebsite.test.edu" {
switch -glob [string tolower [HTTP::uri]] {
"/mytestsite1" { HTTP::redirect "https://mywebsite.test.edu/mytestsite1/Authentication/Login?" }
"/mytestsite1/*" {if {[HTTP::host] ne ""} {
HTTP::header replace Host "differentname.test.edu"
HTTP::uri [string map -nocase {"/mytestsite1/" "/differentname1/"} [HTTP::uri]] }
pool mypool1
return
}
"/mytestsite2" { HTTP::redirect "https://mywebsite.test.edu/mytestsite2/Authentication/Login?" }
"/mytestsite2/*" { if {[HTTP::host] ne ""} {
HTTP::header replace Host "differentname.test.edu"
HTTP::uri [string map -nocase {"/mytestsite2/" "/differentname2/"} [HTTP::uri]] }
pool mypool2
return
}
"/mytestsite3" { HTTP::redirect "https://mywebsite.test.edu/mytestsite3/Authentication/Login?" }
"/mytestsite3/*" { if {[HTTP::host] ne ""} {
HTTP::header replace Host "differentname.test.edu"
HTTP::uri [string map -nocase {"/mytestsite3/" "/differentname3/"} [HTTP::uri]] }
pool mypool3
return
}
}
}
}
}
5 Replies
HTTP::host may contain port number, e.g. aaa.bbb.ccc:8888.
so you need to remove the port number.- rct101
Nimbostratus
Site is using standard HTTPS 443
- HarunTuna
Cirrus
Hi rct101
Can you try below one and let me know if it works ?
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"mywebsite.test.edu" {
switch -glob [string tolower [HTTP::uri]] {
"/mytestsite1" {
HTTP::redirect "https://mywebsite.test.edu/mytestsite1/Authentication/Login?"
}
"/mytestsite1/*" {
if {[HTTP::host] ne ""} {
HTTP::header replace Host "differentname.test.edu"
HTTP::uri [string map -nocase {"/mytestsite1/" "/differentname1/"} [HTTP::uri]]
}
pool mypool1
return
}
"/mytestsite2" {
HTTP::redirect "https://mywebsite.test.edu/mytestsite2/Authentication/Login?"
}
"/mytestsite2/*" {
if {[HTTP::host] ne ""} {
HTTP::header replace Host "differentname.test.edu"
HTTP::uri [string map -nocase {"/mytestsite2/" "/differentname2/"} [HTTP::uri]]
}
pool mypool2
return
}
"/mytestsite3" {
HTTP::redirect "https://mywebsite.test.edu/mytestsite3/Authentication/Login?"
}
"/mytestsite3/*" {
if {[HTTP::host] ne ""} {
HTTP::header replace Host "differentname.test.edu"
HTTP::uri [string map -nocase {"/mytestsite3/" "/differentname3/"} [HTTP::uri]]
}
pool mypool3
return
}
}
}
}
}- rct101
Nimbostratus
This just looks like formatting of the code layout. Went ahead and tried it but no difference.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
