Forum Discussion
Irule redirect link error to default domain
Hello,
I have a domain abc.com new build, i want to redirect all link old or error go to home page, and all the old links have the same structure.
Exam old link: https://test.abc.com.vn/DetailJob.aspx?Mod=search&CatId=21&job=1029042&Lang=vi will be redirect to https://test.abc.com.vn.
I have created an irule as below, but it does not work. Can you help me, please!
when HTTP_REQUEST {
if { [HTTP::host] starts_with "test.abc.com"} {
Pool websitenew
} elseif { [HTTP::host] starts_with "test.abc.com" and [HTTP::uri] ends_with "Lang=vi"} {
HTTP::redirect "https://test.abc.com"
}
}
Hello,
Bind pool 'websitenew' to the virtual server associated with "test.abc.com" and apply below iRule to same VS.
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] ends_with "Lang=vi" } {
http::redirect "https://test.abc.com"
}
}
Hope it helps!
Mayur
- Tuan_Vu
Nimbostratus
hello,
But, i config many site use only IP address. Can you tell me more clearly, Please!
I try:
when HTTP_REQUEST {
if { [HTTP::host] starts_with "test.abc.com"} {
Pool websitenew
} elseif {[string tolower [HTTP::uri]] ends_with "Lang=vi" } {
http::redirect "https://test.abc.com"
}
}
Not working :(
So you mean there are multiple application behind one Virtual Server?
Mayur
- Tuan_Vu
Nimbostratus
Hello Mayur Sutare,
This is currently my irule configuration, can you tell me what I should do to handle the above question?
Thank you !
So alongwith this iRule, you can also bind below separate iRule on same VS. Just keep this iRule above existing iRule. So it will get match first.
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] ends_with "Lang=vi" } {
http::redirect "https://test.abc.com"
}
}
Hope it helps!
Mayur
- Tuan_Vu
Nimbostratus
Hi Mayur,
I don't think so, because some of my sites have the same end. So I want to assign a specific domain test.abc.com.
If I do as you described, it redirects my whole other site?
yes right. In that case, try below iRule which is specific to host.
when HTTP_REQUEST {
if { [HTTP::host] equals "test.abc.com" and [HTTP::uri] ends_with "Lang=vi" } {
HTTP::redirect "https://test.abc.com"
}
}
Mayur
- Tuan_Vu
Nimbostratus
Hi Mayur,
It not working for me. You have know a other solution, help me!
make sure you have new iRule above existing iRule. Also if it is already there, then it seems end statements is not getting matched.
One question here,
is URI 'DetailJob.aspx?Mod=search&CatId=21&job=1029042&Lang=vi' is same all the time?
If yes, then may be you can try below iRule. It is working fine. I've tested it in my lab setup.
when HTTP_REQUEST {
if {[HTTP::host] equals "test.abc.com" and [HTTP::uri] equals "/DetailJob.aspx?Mod=search&CatId=21&job=1029042&Lang=vi"} {
HTTP::redirect "https://test.abc.com"
}
}
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