Redirect requests in ASP.NET from one location to a new location without using much code. You want to use urlMappings in ASP.NET's config files. You want to redirect Googlebot and users alike to the new locations.
We can use urlMappings. This is 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.
| url | mappedUrl |
| ~/Content/Page10.aspx | ~/Content/Int-Parse-Conversion.aspx |
| ~/Content/Page13.aspx | ~/Content/Post-Pre-Build-Macros.aspx |
| ~/Content/Page25.aspx | ~/Content/Programming-Blogs.aspx |
By adding markup to your Web.config file. Remember, the ~ symbol, called a tilde, is a reference to the root of the virtual application directory. That's the root directory of your website. The following code example shows the urlMappings tag.
<!-- Example usage of urlMappings. You will need to customize the 'add'
tags within the urlMappings element. -->
<urlMappings enabled="true">
<!-- Redirect the pages in Google's index... -->
<add url="~/Content/Page22.aspx"
mappedUrl="~/Content/ASP-TreeView-Recursion.aspx"/>
<add url="~/Content/Page9.aspx"
mappedUrl="~/Content/Directed-Acyclic-Word-Graph.aspx"/>
</urlMappings>Use urlMappings as a quick fix for redirecting requests on your 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. [ASP.NET - Rewrite URLs With RewritePath - dotnetperls.com]
Finally, you can instruct the server to send all 404 errors to a certain page. That page can then handle the errors or redirect on its own. [ASP.NET - Server.Transfer to 404 Page - dotnetperls.com]