views:

343

answers:

2

I'm guessing this is actually an impossible task, but I thought I'd run it by StackOverflow to see if I'm wrong. Basically we have some dynamically created URLs for SEO purposes (around 300,000+ of them) and we want to do 301 redirects to them.

Our current URLs look like this:

http://www.site.com/&lt;Brand&gt;/&lt;Product Name>/<productGuid>

Our old URLs looked something like this:

http://www.site.com/productpage.aspx?productGUID=&lt;productGuid&gt;

Google still has a load of the old URLs indexed, but we obviously want them to know that they should be replaced with our newer ones (and that it's not just duplicate content), hence the 301 redirects.

Our problem is that the <Brand> and <Product Name> parts of the new URLs are obviously dynamically created... making it impossible to create 301 redirects for them.

Or is it impossible?

Thanks for any ideas or advice on how we might get Google to start updating their indexed URLs to the new ones.

+1  A: 

On the code for your productpage.aspx page, set the Response.StatusCode and Response.RedirectLocation and end the Response.

Response.StatusCode = 301;
Response.RedirectLocation = "http://www.site.com/&lt;Brand&gt;/&lt;Product Name>/<productGuid>";
Response.End();
thekaido
Thanks for your reply, but the page just redirects itself, even when it's being called by the new URL and not the old one. Any ideas on how to stop that happening?
Django Reinhardt
Try only doing the redirect if it is coming from the old url.
thekaido
Yes, I was wondering how I might go about doing that? Thanks.
Django Reinhardt
Well, a bit of Googling later: Request.Url.AbsoluteUri. Unfortunately it reveals (surprise surprise) that the old URL is what the server sees. In other words, I have no idea how it would be possible for the server to if it was invoked by the old or new URL.
Django Reinhardt
How did you set up your routing to the new url? Is this web forms or mvc?
thekaido
It was done with web forms using URLRewriter.Net
Django Reinhardt
Not sure if this is an option but try using the URL routing in asp.net 3.5sp1 or 4. I have done this exact thing in asp.net mvc but it would be a lot of work to change frameworks.
thekaido
+1  A: 

Create a new internal name for your Product page, for example: ProductPageInternal.aspx.

Rewrite all ProductPage.aspx traffic to a Redirect.aspx page which contains 301 redirect code to the new, nice url.(thekaido's idea)

Rewrite all new Urls to ProductPageInternal.aspx.

<rewrite url="~/ProductPage.aspx?GUID=(.+)" to="~/Redirect.aspx?productGUID=$1" /> 
<rewrite url="~/(.+)/(.+)/(.+)" to="~/productpageInternal.aspx?productGUID=$3" /> 
James Lawruk