Redirect - old site (query string) to AC site

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
dappy2
Commander (CMDR)
Commander (CMDR)
Posts: 114
Joined: Wed Jan 18, 2006 5:53 pm
Contact:

Redirect - old site (query string) to AC site

Post by dappy2 » Wed Feb 11, 2009 8:04 am

Hi,

I'm almost ready to launch my AC site. Unfortunately I'm not sure how to setup my 301 redirects from my old ecommerce site (running Storefront) to the new AC site.

I have complete access to everything from files to the server/ IIS 6.0

I know how to setup redirects in IIS for static pages but I'm not sure what to do about the query strings. For instance I want url.com/detail.aspx?id=23 to be a 301 permanent redirect to the new AC rewritten URL - url.com/some-fancy-product-P2.aspx

Anyone have a way of doing this? All I could find it Google was how to preserve the query string. I'm thinking I have to parse the query string and create a custom redirect in .NET? I don't have a clue how to do that.

Thanks,
Dappy


dappy2
Commander (CMDR)
Commander (CMDR)
Posts: 114
Joined: Wed Jan 18, 2006 5:53 pm
Contact:

Re: Redirect - old site (query string) to AC site

Post by dappy2 » Wed Feb 11, 2009 1:02 pm

That was very helpful.

I don't know C# very well but alot of Googling got me to this if anyone else needs it / sees an error in my ways. I created a detail.aspx page which was very nice since there isn't one for AC and my old software used that with a query string to pull all product date.

Code: Select all

        string storeURL = "http://www.website.com/";
        string newURL;
        string redirectLocation;
        string oldURL = Request.QueryString["ID"].ToString();
        switch (oldURL)
        {
            case "..insert whatever number the old software uses for PRODUCT A here":
                newURL = "...Enter AC URL for PRODUCT A here...";
                break;
     
            default:
                newURL = "default.aspx";
                break;
        }
        redirectLocation = storeURL + newURL;
        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=\"" + redirectLocation + "\">" + redirectLocation + "</a>.</body></html>";
        Response.Write(string.Format(pageContent, redirectLocation));
        Response.End();

dadkind
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Thu Jan 22, 2009 3:32 pm

Re: Redirect - old site (query string) to AC site

Post by dadkind » Wed Feb 11, 2009 4:31 pm

dappy2 wrote:That was very helpful.

I don't know C# very well but alot of Googling got me to this if anyone else needs it / sees an error in my ways. I created a detail.aspx page which was very nice since there isn't one for AC and my old software used that with a query string to pull all product date.

Code: Select all

        string storeURL = "http://www.website.com/";
        string newURL;
        string redirectLocation;
        string oldURL = Request.QueryString["ID"].ToString();
        switch (oldURL)
        {
            case "..insert whatever number the old software uses for PRODUCT A here":
                newURL = "...Enter AC URL for PRODUCT A here...";
                break;
     
            default:
                newURL = "default.aspx";
                break;
        }
        redirectLocation = storeURL + newURL;
        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=\"" + redirectLocation + "\">" + redirectLocation + "</a>.</body></html>";
        Response.Write(string.Format(pageContent, redirectLocation));
        Response.End();

The only problem that I see (and it could be a BIG one) is that you are using a "switch" statement for each and every product in your old store. Imagine the switch statement if you had 1000 products!

A much more efficient way would be to use a database lookup of the new productID and URL using the old productID. This way there the code won't need maintenance as you find additional products to redirect.

Another problem is that StoreFront uses "friendly urls" just like AC7. So while the actual page serving up content is "ProductDetail.aspx?id=123" the URL that you want to redirect is "P-123-My-Sample-Product.aspx". In this scenario, you probably want to be making changes in the Global.asax.cs file, likely somewhere near the BeginRequest function. Otherwise you'll have to create actual pages for all of the pages in the old catalog.

Perhaps someone knows of a regular expression parser in AC7 that can take care of all this for you?

-tomas

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Redirect - old site (query string) to AC site

Post by jmestep » Wed Feb 11, 2009 5:33 pm

This might help- in Able it doesn't matter what the text is in the URL as long as the C# and P# before the .aspx are correct.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

dappy2
Commander (CMDR)
Commander (CMDR)
Posts: 114
Joined: Wed Jan 18, 2006 5:53 pm
Contact:

Re: Redirect - old site (query string) to AC site

Post by dappy2 » Thu Feb 12, 2009 8:15 am

That's helpful. A programmatic way to do it would be ideal. Unfortunately I can't do anything with SQL. And I'm barely surviving C#.

For us at least - we are coming from different e-commerce software (on a server that is going to server heaven after we switch). When we turn off the old e-commerce software there will be a definitive number of product URLs that will never increase because we aren't using that system anymore - we're using AbleCommerce now and everything should be peachy. I just don't want to lose the few top products we have in Google/Froogle. I wouldn't even know where to begin to access another e-commerce DB, figure out what the product is, then figure out what the matching product is in AC, then rewrite the URL...

Thanks for the help,
Dappy

kastnerd
Commodore (COMO)
Commodore (COMO)
Posts: 474
Joined: Wed Oct 22, 2008 9:17 am

Re: Redirect - old site (query string) to AC site

Post by kastnerd » Thu Feb 12, 2009 8:42 am

I was going to use Helicon's ISAPI_Rewrite 3 Lite program when i switch.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Redirect - old site (query string) to AC site

Post by jmestep » Thu Feb 12, 2009 9:55 am

If it is for only a few pages, you could make pages with those names and put a 301 redirect into each to point to the new page. I have done that for a site with the index.aspx to default.aspx Able5/Able7 change.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply