Vince Scordino Team : Web Development Tags : Web Development SEO

Is Your HTTP Redirect Losing Your Querystring?

Vince Scordino Team : Web Development Tags : Web Development SEO

On a recent project, I encountered a strange redirect issue in the production environment. For the sake of SEO and canonical/duplicate content issues, we always setup two websites in IIS; one will have a 301 redirect from a non-www domain to a www domain:

I.e: http://wiliam.com.au -> http://www.wiliam.com.au

I was baffled recently when I was losing the querystring after the redirect happened. The URL was coming from an email where users were asked to activate their registration. Since the URL contained querystring parameters, it was resulting in an error. The issue lies in IIS and how you setup redirect.

Let’s look at how we can ensure the querystring is retained so you don’t fall into the same trap:

  1. Pick the virtual directory you want to redirect. e.g. http://yourdomain.com/
  2. Click HTTP Redirect under IIS in the IIS management console
  3. In the HTTP Redirect Dialog:
    1. Check "Redirect requests to this destination"
    2. Enter your new path ending with $S$Q:
      e.g. http://www.yourdomain.com$S$Q
    3. Counter-intuitively check "Redirect all request to exact destination (instead of relative destination)"
    4. Choose the appropriate "Status Code" (301 Permanent or 302 Temporary)
  4. Apply Changes and Test!

For the full list of allowed URL variables, click here