Forum Discussion

Parveez_70209's avatar
Parveez_70209
Icon for Nimbostratus rankNimbostratus
Mar 16, 2015

Logic to be divided between 301 and 302 redirection

Hi Team,

 

Currently as per the below logic we are having an Irule named: "irule_blocks" containing the below:

 

when HTTP_REQUEST priority 500 { if {[class match [HTTP::uri] contains dg_glob_block_contains]}{ HTTP::redirect "http://www.xyz.com" } elseif {[class match [HTTP::uri] starts_with dg_glob_blocks_starts_with] || [class match [HTTP::uri] starts_with dg_l_mgd_url_blocks] } { HTTP::respond 302 Location "http://www.xyz.com" } }

 

So, as per the existing logic we have : 1) 301 ( permanent) redirects file is “dg_glob_block_contains"

 

2) 302 redirects against Data-Group:"dg_glob_blocks_starts_with" and “dg_lenovo_mgd_url_blocks”

 

Now as per the new Logic we have to do the below: 1) We need "dg_glob_block_contains" & "dg_glob_blocks_starts_with" should be permanent (301 redirect).

 

2) while "dg_l_mgd_url_blocks" should be in 302 redirect.

 

So, how my existing Script/Irule will look like as per the new required logic.

 

Thanks and Regards Pz

 

1 Reply

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Pz,

    Dont you just need to move the start_with if statement up to the redirect section?

    when HTTP_REQUEST priority 500 { 
        if {[class match [HTTP::uri] contains dg_glob_block_contains] || [class match [HTTP::uri] starts_with dg_glob_blocks_starts_with] } { 
          HTTP::redirect "http://www.xyz.com" 
        }
        elseif {[class match [HTTP::uri] starts_with dg_l_mgd_url_blocks] } { 
        HTTP::respond 302 Location "http://www.xyz.com"
        } 
    }
    

    N