Try our conversational search powered by Generative AI!

URL rewrite "on the fly"

Vote:
 

Hi,

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 (www.xyz.com/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. www.xyz.com/customers?country=SE, which only shows customers in Sweden.

Now what we would like to achieve is that when the user selects a country (on the www.xyz.com/customers landing page), he is redirected a new URL instead of using query parameters, e.g. to www.xyz.com/customers/se. 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?

#59629
Jun 19, 2012 16:05
Vote:
 

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

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

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

http://www.david-tec.com/2011/04/Using-IIS7s-URL-Rewrite-feature-to-enable-good-SEO-practice-in-EPiServer/

#59630
Jun 19, 2012 16:16
Vote:
 

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

#59640
Jun 19, 2012 18:47
Vote:
 

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

http://urlrewriter.net/index.php/support/reference/actions/rewrite

David

#59641
Edited, Jun 19, 2012 18:49
Vote:
 

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

#59644
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.