[BIG-IP] F5 大量 redirect 方式
[BIG-IP] F5 大量 redirect 方式
#Step 01 –
設定所需要的 DataGroup
ltm data-group internal bulk-redirect {
records {
www.abc.ca/marrow/BewardsProductList\?a=true&selectedCategoryId=cat70001 {
data xyz.ca/merks
}
www.abc.ca/marrow/Overview {
data test.abc.ca/stashtest
}
www.abc.ca/marrow/Sponsors {
data xyz.ca.ca/stashbwards/list
}
www.abc.ca/marrow/SponsorsDetails\?Nr=vendor.id:100218 {
data xyz.ca.ca/stashrbwards/touterer/88991
}
www.abc.ca/marrow/SponsorsDetails\?Nr=vendor.id:100245 {
data xyz.ca.ca/stashrbwards/boucher/89021
}
www.abc.ca/marrow/Sponsors\?N=105098 {
data xyz.ca.ca/stashbwards/list\?stash_bward_filter=boucherstore
}
www.abc.ca/marrow/Sponsors\?N=105099 {
data xyz.ca.ca/stashrewards/list\?stash_bward_filter=in-store
}
abc.ca/marrow/BewardsProductList\?a=true&selectedCategoryId=cat70001 {
data xyz.ca/merks
}
abc.ca/marrow/Overview {
data test.abc.ca/stashtest
}
abc.ca/marrow/Sponsors {
data xyz.ca.ca/stashbwards/list
}
abc.ca/marrow/SponsorsDetails\?Nr=vendor.id:100218 {
data xyz.ca.ca/stashrbwards/touterer/88991
}
abc.ca/marrow/SponsorsDetails\?Nr=vendor.id:100245 {
data xyz.ca.ca/stashrbwards/boucher/89021
}
abc.ca/marrow/Sponsors\?N=105098 {
data xyz.ca.ca/stashbwards/list\?stash_bward_filter=boucherstore
}
abc.ca/marrow/Sponsors\?N=105099 {
data xyz.ca.ca/stashrewards/list\?stash_bward_filter=in-store
}
}
type string
#Step 02 –
新增 Irule
when HTTP_REQUEST {
if { [class match [HTTP::host][HTTP::uri] equals bulk-redirect] } {
set redirect_value [class match -value [HTTP::host][HTTP::uri] equals bulk-redirect]
HTTP::respond 301 Location "https://$redirect_value"
}
}
當然如果只需要 判斷 Domain 的話
when HTTP_REQUEST {
if { [class match [HTTP::host] equals bulk-redirect] } {
set redirect_value [class match -value [HTTP::host] equals bulk-redirect]
HTTP::respond 301 Location "https://$redirect_value"
}
}
#Step 03 –
不判斷大小寫
when HTTP_REQUEST {
if {[set redir_host [class match -value -- [string tolower [HTTP::host]] equals bulk-redirect]] ne "" }{
HTTP::redirect $redir_host
}
}
when HTTP_REQUEST {
if { [class match [string tolower [HTTP::host][HTTP::uri]] equals bulk-redirect] } {
set redirect_value [class match -value [string tolower [HTTP::host][HTTP::uri]] equals bulk-redirect]
HTTP::respond 301 Location "https://$redirect_value"
}
}
#Step 04 –
當然也可使用不套用 Datagroup 方式
when HTTP_REQUEST {
if { [HTTP::host] equals "www.abc.ca" || [HTTP::host] equals "abc.ca" } {
switch -glob [string tolower [HTTP::uri]] {
"/marrow/overview/" { HTTP::respond 301 Location "https://test.abc.ca/stashtest" }
"/marrow/sponsors" { HTTP::respond 301 Location "https://xyz.ca.ca/stashbwards/list" }
"/marrow/sponsors?n=105098" { HTTP::respond 301 Location "https://xyz.ca.ca/stashbwards/list?stash_bward_filter=boucher" }
"/marrow/sponsors?n=105099" { HTTP::respond 301 Location "https://xyz.ca.ca/stashrewards/list?stash_bward_filter=in-store" }
"/marrow/sponsorsdetails?nr=vendor.id:100218" { HTTP::respond 301 Location "https://xyz.ca.ca/stashrbwards/touterer/88991" }
"/marrow/sponsorsdetails?nr=vendor.id:100245" { HTTP::respond 301 Location "https://xyz.ca.ca/stashrbwards/touterer/89021" }
"/bewardsproductlist?a=true&selectedcategoryid=cat70001" { HTTP::respond 301 Location "https://xyz.ca/merks" }
}
}
}
不過這樣 irule的行數 就會多很多 也可能造成 修改上的出錯率
#Step 05 –
#Step 06 –
#Step 07 –
#Step 08 –
#Step 09 –
#Step 10 –
沒有留言:
張貼留言