0

I have just ported an HTML site over to ASP.NET MVC 3.

Google appears to have a lot of the old pages indexed, e.g.

http://www.foo.com/bar.html

and now this will be

http://www.foo.com/bar

I'd like a way to force users and Google to be permanently redirected to the new URL structure. Some of the redirects aren't as simple as dropping the .html, so the ability to fine-tune the redirect paths would be great.

I'm hosting on Windows Server 2008 R2, so if I can do this through IIS then great, else I don't mind implementing something in code.

Any ideas please?

I've had a hunt round Google, but not found anything that seems to fit the bill.

Thanks.

Mike
  • 6,149
  • 5
  • 34
  • 45

2 Answers2

1

I'd set up a catch-all route and a Redirects table in your DB. In a catch-all handle I'd check if there's an entry for a requested URL in the Redirects and redirect to a new URL.

Community
  • 1
  • 1
Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
  • Cool, that sounds like quite a good idea thanks. I'll set up some cached data to define re-direct routes, e.g. /Bar.html goes to Controller 'Bar' and Action 'Index' and then for anything that doesn't fit the bill I'll redirect to my errors controller for a 404. Thanks. – Mike Jun 06 '11 at 10:45
  • One more thing - do you know if this will be equivalent to a 301 permanent redirect? I want Google to realise that the old URLs are no longer correct. – Mike Jun 06 '11 at 10:49
1

have you allready tried to add additonal routes to your routing table. here is an article that describes routing in mvc.

http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx

Volkmar Rigo
  • 1,158
  • 18
  • 32