Try our conversational search powered by Generative AI!

URL rewrite "on the fly"



The topic might be misleading, but could not come up with anything better. Here is a concrete scenario:

Let's say I have a page called Customers ( On this page, the user can select a country (dropdownlist) to show only customers located in this specific country. Today this this is solved by using the same page with a query parameter, e.g., which only shows customers in Sweden.

Now what we would like to achieve is that when the user selects a country (on the landing page), he is redirected a new URL instead of using query parameters, e.g. to We would like to achieve this for a couple of reasons, for instance to be able to track how many users that specifically looked at the swedish customers (e.g. by monitoring that specific URL in Google Analytics). Another perspective is SEO.

The list of selectable countries is created dynamically based on the what exists in a database (i.e. I cannot predefine pages in the page structure to redirect to).

How can I achieve this? Is there some kind of URL rewrite mechanism that I can utilize for this only?

Jun 19, 2012 16:05

You can use the IIS rewrite module with the following rule:

        <rule name="CountryRewriter" stopProcessing="true">
          <match url="^([^/]+)/customers/([^/]+)/?$" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          <action type="Rewrite" url="/{R:1}/customers/?country={R:2}" />

You can read more about using this in EPiServer on my blog:

Jun 19, 2012 16:16

Thanks David, very interesting! Unfortunately we are still stuck in the IIS 6 mud...any options?

Jun 19, 2012 18:47

In that case I would try You can achieve the same result using it. This page describes how this is possible:


Edited, Jun 19, 2012 18:49

Much appreciated! I have not decided which way to go yet, thus I will mark both suggestions as answers. Thank you!

Jun 19, 2012 23:12
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.