cancel
Showing results for 
Search instead for 
Did you mean: 

irule with default redirect to home page.

Hien_Truong
Cirrus
Cirrus

i have irule with redirect some uri and the rest of them redirect to the Home page. i don't know why it is not go to home page. i appreciate your help.

Thanks

 

when HTTP_REQUEST { 

 if { [HTTP::host] equals "www.ABC.com" } 

 {

 switch -glob [HTTP::path]

 {

  "/Content" 

   { HTTP::respond 301 Location "https://www.CDF.com/legacy/Content" 

   }

  "/Programs" 

   { HTTP::respond 301 Location "https://www.CDF.com/legacy/Programs" 

   }

 default

 {HTTP::respond "https://www.CDF.com"}    

}

}

}

4 REPLIES 4

Hi Hien Truong,

 

Can you add "30x Location" after "HTTP::respond" for default case?

or you can use HTTP::redirect

# 301 default { HTTP::respond 301 Location "https://www.CDF.com" }   # 302 default { HTTP::redirect "https://www.CDF.com" }

 

Hien_Truong
Cirrus
Cirrus

Hi Enes;

i appreciate for your reply, i tried to change both # 301 or #302 in my irule, when typing www.ABC.com, it redirect to www.CDF.com (that's good) but when i type www.ABC.com/#about for example, it will redirect to www.CDF.com/#about. we want the rest of them go to home page www.CDF.com only (beside of /Content and /Programs). Any input i appreciate it.

Thanks

Considering your VIP is hosting many applications and this rule should only be applied for www.abc.com HOST. You can try the below iRule

 

when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] switch -glob [string tolower [HTTP::host]] { "www.abc.com" { if {$uri starts_with "/content" or $uri starts_with "/programs" } { HTTP::respond 301 Location "https://www.cdf.com/legacy[HTTP::uri]" } else { HTTP::respond 301 Location "https://www.cdf.com" } } default { return } } }

 

Hien_Truong
Cirrus
Cirrus

it works, thanks for your support.