Multiple Web Sites with Individual Domains
If you want to host multiple individual web sites in IIS, you just need to Create a Web Site for each web site, then Add a Binding for the domain name. IIS supports this out of the box, so there is no need for URL rewriting in this case.
A Multi-tenant Web Site with More than One Domain Name
In this case, using .NET Routing is far preferable to URL Rewriting.
URL Rewriting is effectively dead in .NET Core. It was needed in early versions of ASP.NET because the .aspx
, .ashx
, and .asmx
handlers were file-based and if you wanted the URL to be different than the file name, you had to rewrite the incoming request to the file name. This was just a way to "fake" URLs by plugging different values into the HTTP request than the real values.
Rewriting caused several issues though, especially for components that relied on those HTTP request values to accurately represent the request.
However, years ago ASP.NET Routing was created. No more faking the HTTP Context - routing goes directly to the resource that is requested without rewriting and without redirecting. Even better: routing manages all of the URL activity for the entire application. Not only will it send an incoming URL to an exact page or action method, it can also be used to generate URLs to be used in hyperlinks, JavaScript, for redirects, etc. What this effectively means is that if you change the URL of a route, it will automatically update everywhere in the application.
Another difference is that routing doesn't map a URL to another URL, in MVC it maps a URL to a dictionary of route values. For example, you can map the URL apple
to controller="Fruits", action="Apple"
. MVC will then respond by executing the FruitsController.Apple
action method when you go to http://www.somesite.com/apple
.
So, for all modern apps use .NET Routing instead of URL rewriting.
Reference: Routing in ASP.NET Core