Forum Discussion

Chris_Olson's avatar
Chris_Olson
Icon for Nimbostratus rankNimbostratus
Aug 29, 2011

Redirect loses trailing "/"

I have some odd behavior on an HTTP redirect. Testing a site locally without adding a trailing "/" at the site name works fine. However, going through the F5 requires that the trailing "/" be entered manually for the site to come up. I cannot convince the business to force clients to add this to the URL manually. The activty appears that we are being redirected back to http and it fails. Seems like the rule will redirect to https but then will get redirected back to http if the "/" isn't present. Is it the pool redirect rule that is causing it?

 

Here are the rules:

 

 

____________________________________________________________

 

HTTPS redirect Rule (on the 80 VIP)____________________________________________________________

 

 

when HTTP_REQUEST {

 

switch [getfield [string tolower [HTTP::uri]] "/" 2] {

 

prod { HTTP::redirect [HTTP::host] ":" 1][HTTP::uri] }

 

prod-uat { HTTP::redirect [HTTP::host] ":" 1][HTTP::uri] }

 

prod-stg { HTTP::redirect [HTTP::host] ":" 1][HTTP::uri] }

 

prod-sales { HTTP::redirect [HTTP::host] ":" 1][HTTP::uri] }

 

}

 

}

 

___________________________________________________________________

 

 

Pool redirect Rule (on the 443 VIP)

 

____________________________________________________________________

 

when HTTP_REQUEST {

 

switch [getfield [string tolower [HTTP::uri]] "/" 2] {

 

prod { pool pool_2011.1_PROD }

 

prod-uat { pool pool_2011.1_UAT }

 

prod-sales { pool pool_2011.1_Sales }

 

prod-stg { pool pool_2011.1_Stage }

 

}

 

}

 

___________________________________________________________________

 

RESULTS

 

 

wget

 

http://www.website.com/prod-uat

 

--12:38:57-- http://www.website.com/prod-uat

 

=> `prod-uat'

 

Resolving www.website.com... 999.999.999.99

 

Connecting to ... connected.

 

HTTP request sent, awaiting response... 302 Found

 

Location: https://www.website.com/prod-uat [following]

 

--12:38:57-- https://www.website.com/prod-uat

 

=> `prod-uat'

 

Connecting to ... connected.

 

HTTP request sent, awaiting response... 301 Moved Permanently

 

Location: http://www.website.com/prod%2Duat/ [following]

 

--12:38:58-- http://www.website.com/prod%2Duat/

 

=> `index.html'

 

Connecting to ... connected.

 

HTTP request sent, awaiting response... 404 Not Found

 

12:38:58 ERROR 404: Not Found.

wget

 

http://www.website.com/prod-sales

 

--12:39:14-- http://www.website.com/prod-sales

 

=> `prod-sales'

 

Resolving www.website.com... 999.999.999.99

 

Connecting to ... connected.

 

HTTP request sent, awaiting response... 302 Found

 

Location: https://www.website.com/prod-sales [following]

 

--12:39:15-- https://www.website.com/prod-sales

 

=> `prod-sales'

 

Connecting to ... connected.

 

HTTP request sent, awaiting response... 301 Moved Permanently

 

Location: http://www.website.com/prod%2Dsales/ [following]

 

--12:39:15-- http://www.website.com/prod%2Dsales/

 

=> `index.html'

 

Connecting to ... connected.

 

HTTP request sent, awaiting response... 404 Not Found

 

12:39:15 ERROR 404: Not Found.

 

4 Replies

  • Hi Chris,

     

    Wouldn't you simply add the trailing / within the iRule section of where the redirect is?

     

     

    Bhattman
  • Sure, if I knew enough about the syntax of the rule itself. My best guess is just before the number one as shown below? Could it be that simple?

     

     

    I am very sorry, but my lack of experience is clearly being exposed at this point.

     

     

    prod-uat { HTTP::redirect [HTTP::host] ":" /1][HTTP::uri] }

     

  • Hi Chris,

     

    More like the following:

     

    prod-uat { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]/ }

     

     

    Bhattman
  • You may also consider using redirect rewrite in the HTTP profile - see the section on trailing slash redirects:

     

    http://support.f5.com/kb/en-us/solutions/public/6000/900/sol6912.html?sr=16353274

     

     

    --Matt