Forum Discussion

nrelihan_68143's avatar
nrelihan_68143
Icon for Nimbostratus rankNimbostratus
Oct 19, 2011

Change HTTP redirect header question

Hey,

 

 

I'm currently doing a uri redirect which redirects traffic, so that traffic from one region will be redirected to their particular page: eg.

 

 

switch [whereis [IP::client_addr] country] {

 

 

"IE" {

 

 

if {$hostname eq "www.example.com" }

 

 

{ HTTP::redirect http://www.example.com/ireland

 

 

I would like to change the redirect header from 302 to a 301 redirect. The reason being is so that crawlers can be redirected also without affecting my google page rank. currently I have an exception in the irule so that crawlers are not redirected.

 

 

Thanks for any suggestions.

 

 

Neil

 

2 Replies

  • Hi nrelihan,

     

     

    It is a simple change using HTTP::respond (http://devcentral.f5.com/wiki/iRules.HTTP__respond.ashx) instead of HTTP::redirect.

     

     

    When HTTP::respond you get to specify the HTTP::status code that is returned.

     

     

    Hope this helps.
  • Hey Michael,

     

     

    Yes that makes sense, I remember I was using HTTP::respond 302 location before, and someone said I could just use HTTP::redirect instead. So I will just edit my code like so:

     

     

    switch [whereis [IP::client_addr] country] {

     

     

    "IE" {

     

     

    if {$hostname eq "www.example.com" }

     

     

    { HTTP::respond 301 location "http://www.example.com/ireland"

     

     

    Or can I leave out the quotes around http://www.example.com/ireland"?

     

     

    Cheers.