ASP.NET UrlMappings Example: RedirectsUse the UrlMappings element in Web.config for simple rewrite rules.
UrlMappings. The urlMappings element redirects URLs to new locations. This element is part of an ASP.NET config file. It redirects Googlebot and users alike to the new locations. It is easily added to Web.config to perform this complex task.
Example. We can use urlMappings, a special tag you can put in your Web.sitemap. Here is a table of some "old style" URLs that I want to map to new URLs. You can see the new URLs had SEO improvements with more keywords.
Example 2. You can add urlMappings by adding markup to Web.config. The "~" symbol, called a tilde, is a reference to the root of the virtual application directory. That is the root directory of your website. This example shows the urlMappings tag.
Examples for, url:
~/Content/Page10.aspx ~/Content/Page13.aspx ~/Content/Page25.aspx
~/Content/Int-Parse-Conversion.aspx ~/Content/Post-Pre-Build-Macros.aspx ~/Content/Programming-Blogs.aspx
Open Web.config. This file is part of your website project in the Solution Explorer. You will need to double-click on it. Next, find the system.web element. Locate the <system.web> element and its closing tag.
Then Put your <urlMappings> block into a section in the middle of that section.
Web.config examples, XML:
<urlMappings enabled="true"> <add url="~/Content/Page22.aspx" mappedUrl="~/Content/ASP-TreeView-Recursion.aspx"/> <add url="~/Content/Page9.aspx" mappedUrl="~/Content/Directed-Acyclic-Word-Graph.aspx"/> </urlMappings>
Summary. We used urlMappings as a quick fix for redirecting requests on an ASP.NET server. There are other methods that may be more powerful. Use the RewritePath method in ASP.NET and Global.asax for a more flexible approach.
© 2007-2022 sam allen.
see site info on the changelog.