I am on the verge of releasing/replacing a site for a client. I am wondering what the best way of dealing with redirects from old (no longer existing) pages to the new equivalent page (differnt url).
Example:
site.com/product/page.aspx
should redirect to site.com/newstructure/stuff.aspx
I'm looking for a solid central way of handling all these redirects (301:s).
Creating paths for old pages and simply redirects from there is not really a good solution. Can I use Url Mappings in Web.config for this? Should I use global.asax?
I would suggest using URL Rewrite module and then setting up the rules. Your urls probably won't match, so you would have to map them manually (anyways it's much better to do it manually as this is the most reliable way).
If you are looking for a module then have a look at the below url.
http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/
Depending on which IIS you are running it under, you might want to find different version of the rewrite module.
Hope that helps.
To not lose your google position you need to make a 301 Permanent Redirect
from page to page.
RedirectPermanent("newpage.aspx");
Now, if you have made a table, from old page to new pages, you can apply it to global.asax as:
// initialize this list on start of your program
Dictionary<string,string> oMapOldToNew = new Dictionary<string,string>();
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string cTheFile = HttpContext.Current.Request.Path;
if(oMapOldToNew.ContainsKey(cTheFile))
{
Response.RedirectPermanent(oMapOldToNew[cTheFile], true);
return;
}
}
RedirectPermanent ref: http://msdn.microsoft.com/en-us/library/dd322042.aspx