Upgrade from 1.9 to 2.3, SEO URL Changing

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 12 ans
Hello,

My website is currently running on 1.9 and I want to upgrade to 2.3. I notice that the url of 2.3 is without the aspx and some of the numbers are changed to be different. I have so many backlinks pointing to my website. If I do the upgrade, is there a way that I can keep all my url to be the same? If not, then I would lose all my inbound links.
Please help, thanks
Toan
Il y a 12 ans
All links have new formats in 2.X version. But no worries about 1.X links. All of them will also work in 2.X
Il y a 12 ans
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=93633
Please 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.
Il y a 12 ans
nopworks wrote:
no, the links with .aspx extension going to 404 errors and what about search engines cache?

It works fine. Test it on our [url=demo.nopcommerce.com/]demo site[/url]. http://demo.nopcommerce.com/products/1-sdf.aspx will redirect you to http://demo.nopcommerce.com/p/1/5-virtual-gift-card.

P.S. All redirects (permanent) are handled by the following file: \Presentation\Nop.Web\Controllers\BackwardCompatibility1XController.cs
Il y a 12 ans
It`s not working properly.

Sample, in old system demo was url http://demo.nopcommerce.com/p/1-5-virtual-gift-card.aspx (productId = 1, SEName=5-virtual-gift-card).

Please try go to http://demo.nopcommerce.com/p/1-5-virtual-gift-card.aspx you will get custom error with 302 status code (it must be 404 or 301 with redirect to http://demo.nopcommerce.com/p/1/5-virtual-gift-card)

If i upgrade system on my site, http://www.climatik.dp.ua/p/30-dekker-dsh105rl.aspx it will not work, tested on localhost.

Thank You
Il y a 12 ans
It works fine!

nopworks wrote:
In old system demo was url http://demo.nopcommerce.com/products/1-sdf.aspx ("/products/", not "/p")!

You have non-standard URLs in 1.90 (maybe, you changed it). So if you want to redirect from .../p/1-productname.aspx to the new URL, then follow the next steps:
1. Open \Presentation\Nop.Web\Infrastructure\UpgradeRouteProvider.cs
2. Find
routes.MapRoute("", "products/{id}.aspx",
   new { controller = "BackwardCompatibility1X", action = "RedirectProduct"},
   new[] { "Nop.Web.Controllers" });

and replace it with
routes.MapRoute("", "p/{id}.aspx",
   new { controller = "BackwardCompatibility1X", action = "RedirectProduct"},
   new[] { "Nop.Web.Controllers" });
Il y a 12 ans
Yes, i changed url pattern in old system.

Thank You Andrei
Il y a 12 ans
Great work by all nopcommerce developers. Well done.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.