cancel
Showing results for 
Search instead for 
Did you mean: 

Irule redirect link error to default domain

Tuan_Vu
Nimbostratus
Nimbostratus

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"

  }

}

 

9 REPLIES 9

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

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

Hello Mayur Sutare,

 

This is currently my irule configuration, can you tell me what I should do to handle the above question?

 

Thank you !

 

0691T000008GqD6QAK.png

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

 

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

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"

 

}

 

}