Forum Discussion

discovinnie_148's avatar
discovinnie_148
Icon for Nimbostratus rankNimbostratus
Mar 21, 2014

301 redirect

HI,

 

I need to get a specific uri that is giving a 302 redirect to respond with a 301:

 

when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/x648.html" } { HTTP::respond 301 Location [string map -nocase {"/x648.html" "/LegacyPublications"} [HTTP::uri]] } }

 

No matter what I try I get don't get the 301 redirect.

 

Thanks for the help

 

2 Replies

  • Hi!

     

    Have you tried some debug logging? Check if the if statement is triggered by issuing this within the if statement:

     

    Log local0. "Triggered for [HTTP::uri]"

     

    I would also log your string map to verify the output.

     

    /Patrik

     

  • The Location header should be absolute ie

    Location "http://[HTTP::host][string map -nocase {"/x648.html" "/LegacyPublications"} [HTTP::uri]]"
    

    I can't say for sure if this is your problem, but a relative one will not work for all browsers AFAIK.