CMS

Adding backslash ending to your URLs by UrlRewrite

It's generally a best practice to add a backslash to your URLs, for performance reasons (let's get back to that later in another post). There are several ways to do it, but the best/simplest way, IMO, is using UrlRewrite module. In most of the case, processing the Urls before it reaching the server code will be most effective, and here by using UrlRewrite we trust IIS to do the right thing. Our application does not even need to know about it. It's also a matter of reusable. You can simply copy a working, well tested rule to another sites without having to worry much about compatibility. Before getting started, it's worth noting that UrlRewrite is an IIS module which is not installed by default, if you want to use it, then you would have to install it explicitly. Download and install it from https://www.iis.net/downloads/microsoft/url-rewrite . And then we can simple add rules to <system.webServer><rewrite><rules> section in web.config. For the purpose of this post, this rule should be enough: [crayon-5ab67441ded71593892082/] If you are new to UrlRewrite, may be it's useful to explain a bit on the rule. Here we want to add a rule which matches every url, except the urls which already end with backslash (/) already. (more…)

By vimvq1987, ago