Page 1 of 1
Redirect - old site (query string) to AC site
Posted: Wed Feb 11, 2009 8:04 am
by dappy2
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
Re: Redirect - old site (query string) to AC site
Posted: Wed Feb 11, 2009 10:18 am
by mazhar
Re: Redirect - old site (query string) to AC site
Posted: Wed Feb 11, 2009 1:02 pm
by dappy2
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();
Re: Redirect - old site (query string) to AC site
Posted: Wed Feb 11, 2009 4:31 pm
by dadkind
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
Re: Redirect - old site (query string) to AC site
Posted: Wed Feb 11, 2009 5:33 pm
by jmestep
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.
Re: Redirect - old site (query string) to AC site
Posted: Thu Feb 12, 2009 8:15 am
by dappy2
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
Re: Redirect - old site (query string) to AC site
Posted: Thu Feb 12, 2009 8:42 am
by kastnerd
I was going to use Helicon's ISAPI_Rewrite 3 Lite program when i switch.
Re: Redirect - old site (query string) to AC site
Posted: Thu Feb 12, 2009 9:55 am
by jmestep
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.