Hello,
no, the links with .aspx extension going to 404 errors and what about search engines cache?
http://www.google.com/support/webmasters/bin/answer.py?answer=93633Please edit Global.asax (in source)
add to namespaces
using System.Text;
using System.Text.RegularExpressions;
Find Application_Error method and add after LogException(Server.GetLastError()); code
//added
Exception ex = Server.GetLastError();
//added for 404 error
if (ex is HttpException)
{
if (((HttpException)(ex)).GetHttpCode() == 404)
{
HttpContext context = (sender as HttpApplication).Context;
if (context.Request.PhysicalPath.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase))
{
var webHelper = EngineContext.Current.Resolve<IWebHelper>();
// Get current HttpApplication Request
HttpApplication hxa = (HttpApplication)sender;
//Get Incoming Request for page.
string originalUrl = hxa.Context.Request.Url.ToString();
string patternProduct = String.Empty;
string patternCategory = String.Empty;
string patternManufacturer = String.Empty;
string patternSimplePage= String.Empty;
patternProduct = @"/p/(\d{1,10})-([A-Za-z0-9\-]+)\.aspx$";
patternCategory = @"/c/(\d{1,10})-([A-Za-z0-9\-]+)\.aspx$";
patternManufacturer = @"/m/(\d{1,10})-([A-Za-z0-9\-]+)\.aspx$";
Match matchProduct = Regex.Match(originalUrl.ToLower(), patternProduct);
Match matchCategory = Regex.Match(originalUrl.ToLower(), patternCategory);
Match matchManufacturer = Regex.Match(originalUrl.ToLower(), patternManufacturer);
//redirect to new url
string newUrl = String.Empty;
//@redirect to new url
// Try and Check for redirect
try
{
if (matchProduct.Success)
newUrl = string.Format("{0}p/{1}/{2}", webHelper.GetStoreLocation(), matchProduct.Groups[1].Value, matchProduct.Groups[2].Value);
if (matchCategory.Success)
newUrl = string.Format("{0}c/{1}/{2}", webHelper.GetStoreLocation(), matchCategory.Groups[1].Value, matchCategory.Groups[2].Value);
if (matchManufacturer.Success)
newUrl = string.Format("{0}m/{1}/{2}", webHelper.GetStoreLocation(), matchManufacturer.Groups[1].Value, matchManufacturer.Groups[2].Value);
if (!String.IsNullOrEmpty(newUrl))
{
context.Response.Clear();
context.Response.StatusCode = 301;
context.Response.AppendHeader("location", newUrl);
context.Response.End();
}
else
{
Response.StatusCode = 404;
}
}
catch (Exception)
{
//Redirect to page not found if we have an error
hxa.Response.AddHeader("Location", webHelper.GetStoreLocation());
}
}
else
{
Response.StatusCode = 404;
}
}
}
Most likely you need make changes, eg. if your url`s of pages in 1.x versions had pattern "../product/.. "you need change pattern to
@"/product/(\d{1,10})-([A-Za-z0-9\-]+)\.aspx$"
This is a simplest method, but better implementation will be: get product by id and redirect to new. Code was tested on localhost and return correct 301 redirect to new.