50,000+ 301 Redirects

I’m working on a SEO/Human friendly URL solution for a large website.

All the links on the website will remain in their old lengthy format, however I would like the user only ever see new nicely formatted urls in their browser bar.

old - domain.com/blah/blah/blah/index.cfm?id=12345
new - domain.com/area_name/12345-short-title

The area name and short title are only available through the database, so I intend to setup an apache rewrite rule to forward all OLD URLs to a ‘redirect.cfm’
The redirect.cfm will build the new URL and perform a 301 redirect to it.

Apache rewrite will pick up the new URL and this time send it to ‘content.cfm’ to display the content.

Hitting the database every time a URL is requested seems excessive, and it has been suggested when I build the new URL I also add a new line in the htaccess file, a 301 redirect, so next time database access is not required.

I predict at least 50,000 redirects being created, after some Google searching I am unsure on whether this is an efficient solution. I saw another post in this forum which said

If you’re on a dedicated server, at least put everything in your virtual host config as that’s loaded in RAM when Apache starts up. .htaccess is a poor man’s solution to Apache configuration. It should only be used when you have no other choice.

I do not know what virtual host config is, or whether I can append it via ColdFusion. Can anyone help me out with a viable solution?

Have you profiled the performance here? It really should not kill you if you have your indexes setup correctly and you aren’t talking OMG WEBSCALE traffic. If you are talking that kind of traffic then you probably have the hardware to handle it.

I would also look at ColdFusion’s caching, this is a perfect candidate for that sort of thing.

I guess it’s not ‘OMG WEBSCALE traffic’ :slight_smile:

August 2012
Visits: 57,977
Unique Visitors: 48,979
Pageviews: 163,488

The hardware does need an upgrade and that’s in the works.

Otherwise no, I haven’t test the performance - I’m still putting this together as a proposal. I understand your point though, we should probably at least test it.

Yeah, I’d just run with dynamic lookups, 1st fallback to CFM caching, 2nd fallback to generating a static file from the database. No need to build more infrastructure than you need, and depending on traffic patterns the redirects will fall off pretty quickly – a good 301 strategy is really about getting google to update their links, no?