In this recipe, we will learn how to create SEO-friendly routes. To do this, we can use the MVC routing system, the IIS UrlRewriting
module, or both.
There are some scenarios where thinking about SEO is mandatory.
We are creating a new version of our website with MVC. But we have a lot of legacy URLs that are already used, or were recorded before the MVC version of our application. We also spent a lot of money for buying keyword to motorsearch as Google to throw all these URLs.
To manage this problem, we will use the IIS UrlRewriting
module to redirect the legacy URLs to corresponding controller as an action.
- First, we have to install the
UrlRewriting
module usingWeb Plateform
Installer
:
- Next, we add a rule to redirect a legacy URL such as
http://localhost:1962/products.ASPX?lang=fr-FR&category=smartphone&subcategory=samsung&id=cadc5808-75a7-4428-b491-3cacfe37d9ce
to this existing MUV route:http://localhost:1962/fr-FR/products...