301 URL Redirect Pages for AbleCommerce

From AbleCommerce Wiki
Jump to: navigation, search

301 redirect is an efficient and Search Engine Friendly method for redirecting webpages. Its easy to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it's the safest option. The code "301" is interpreted as "moved permanently". For example if you have some blah.aspx product page which is not working in AbleCommerce 7 because AbleCommerce seven uses some different URL for that page. You can solve this problem by creating a 301 Redirect page for your AbleCommerce store in the following way.

  • Create an aspx page with the same name as of the page that is moved in our case the blah.aspx

in the proper directory. The page language must be C#

  • Now add the following code to the Page_Init function
     private void Page_Init(object sender, System.EventArgs e)
     {
           string redirectLocation = "New URL Here";
           Response.Clear();
           Response.Status = "301 Moved Permanently";
           Response.AddHeader("Location", redirectLocation);
           string pageContent = "<html><head><title>Object moved</title></head><body>-Object Moved-This object may be found at <a href=\"{0}\">{0}</a>.</body></html>";
           Response.Write(string.Format(pageContent, redirectLocation));
           Response.End();
     }

Now Just provide your new URL in place of "New URL Here" in the above function. For example

     string redirectLocation = "yourstoreurl/someproduct.aspx";

And you are done with 301 Page redirect for blah.aspx that was all you have to done for page redirect to work.