Setting Up Simple URL Rewriting In Ucommerce
In order to use the URL engine in Ucommerce, you need a set of IIS rewrite rules, that would make sure that your URLs point at correct pages in the CMS and the CatalogContext is populated correctly.
You can configure custom IIS rewrite rules in
<rule name="DefaultCategoryProductRewrite"> <match url="(.*)/c-([0-9]+)/c-([0-9]+)/p-([0-9]+)" /> <action type="Rewrite" url="catalog/product.aspx?catalog={R:2}&category={R:3}&product={R:4}" /> </rule> <rule name="DefaultProductRewrite"> <match url="(.*)/c-([0-9]+)/p-([0-9]+)" /> <action type="Rewrite" url="product.aspx?catalog={R:2}&product={R:3}" /> </rule> <rule name="DefaultCategoryRewrite"> <match url="(.*)/c-([0-9]+)/c-([0-9]+)" /> <action type="Rewrite" url="catalog.aspx?catalog={R:2}&category={R:3}" /> </rule> <rule name="DefaultCatalogRewrite"> <match url="(.*)/c-([0-9]+)" /> <action type="Rewrite" url="catalog.aspx?catalog={R:2}" /> </rule>
This gives you pretty URLs, like these for example:
Page | Sample url |
---|---|
Catalog - demo-store | demo-store/c-24 |
Category - Formal | demo-store/tops/formal/c-24/c-70 |
Product | demo-store/tops/formal/blue-kittens-shirt/c-24/c-70/p-110 |
Ucommerce demo stores serve as an inspiration for getting started in the development of your own store. This store comes with a fully working example of the URL rewrite rules.
The examples above are simple examples, which you probably need to adjust to your client’s needs, and your site structure. For a more comprehensive documentation on how to configure rewriting, check out the documentation for the IIS Rewrite Module 2.
In case you want to set up multilingual URL rewrite rules in Kentico, please follow the article Multilingual URLs in Kentico.