Trailing Slashes, IIS and F5 / Big-IP

We’ve had a problem on our websites at work for the last couple years where if a user doesn’t use a trailing slash when visiting a directory, ie:

the user gets a “The page cannot be displayed” error. The problem is that if you don’t use a trailing slash IIS sends a redirection to use the trailing slash:

GET /mydirectory HTTP/1.1

HTTP/1.x 302 Object Moved

Notice that the redirect includes the port designation? We run multiple websites on a single box and (for reasons beyond me) we don't use host headers so we have to use non standard ports in IIS. In the case above the web server thinks it's running the site on port xxx, which it technically is, but the world doesn't see that, nor can it use that port to access the site. At the time I thought it was the F5 that was redirecting users inappropriately, but there was nothing on the F5 website to back that up. There is now: How do I stop redirects from the web server behind BIG-IP?

In short, any website (IIS or Apache) running behind the F5 / Big-IP that is not using port 80 will show this behavior, there are a couple fixes:

a) use an IIS ISAPI filter (or mod_rewrite on Apache) to rewrite the redirects

b) use an F5 / Big-IP port redirect rule

c) use an F5 / Big-IP trailing slash redirect rule

If you read the tech note you'll see that Option 'b' will result in 2 redirects (client requests --> IIS redirects to --> Big-IP redirects to and also lets any technical users know which port we're running on websites. Option 'c' is mentioned in the tech note as being the last gasp: "F5 Networks recommends using this rule only if there is no other alternative" so I chose option 'a'. There is a free ISAPI rewrite engine called (conveniently) ISAPI_Rewrite from I installed it and then added the appropriate rewrite rule:

RewriteCond Host: (.*)
RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,R]

and everything works again. Balance has been restored to the world.

One thought on “Trailing Slashes, IIS and F5 / Big-IP”

Leave a Reply

Your email address will not be published. Required fields are marked *