WebFaction
Community site: login faq

I'm migrating a site with thousands of pages, where:

domain.com/old-URL.html should redirect to domain.com/completely-different-URL

I don't want to lose Google rankings, but I know that if I create an htaccess file with 1200 URLs in it, it's going to take a huge toll on site-load speed. How can I accomplish this this without impacting site-load speed? Because the old and new URLs are different, a regular expression won't work.

The old site was simple HTML. The new site is WordPress.

asked 16 Jul '14, 00:25

PeterA
10431022
accept rate: 14%

edited 16 Jul '14, 01:59


There are a few ways to implement this, but matching every incoming request against a list of redirects is going to have a performance cost one way or another.

The fastest way might be adding a thin "middleware" CGI layer that operates on the incoming requests after the requests passes through .htaccess and make this CGI layer a small C binary that either issues a 301 redirect response or passes the request on. This would probably be implemented as a call to the binary from PHP, so that's not particularly efficient, but it might be faster than the .htaccess method. Or, the .htaccess method might be fastest (after all, Apache is in C and you won't need an extra fork/exec this way). You'd really have to test and benchmark to be sure.

Either way, if your main concern is rankings, then I'd put up with the performance penalty and do what it takes to make sure the 301 redirects work. This would be temporary; the redirects may only need to remain in place for a few weeks, until Google fully indexes the redirects and has crawled the redirected pages a few times. It may be fine to just put the redirects directly in .htaccess for a month or so, and then slowly remove them while monitoring rankings.

permanent link

answered 16 Jul '14, 06:31

ryans ♦♦
5.0k93260
accept rate: 43%

Thanks for the great explanation, Ryan. What do you think about the relative impact of .htaccess vs. the database solution in the answer I just posted? We use memcached, so our database queries get cached for a while…

Also I read several several articles suggesting the use of RewriteMap in the vhost file, but it sounds like there's no way to do that at the user level, only as root.

(16 Jul '14, 14:54) PeterA

If you're caching your DB queries in memcached, then your solution seems reasonable to me. If you're wondering about relative performance, the only way to answer that would be to load test your site in both configurations and see which configuration gives you the best performance.

(17 Jul '14, 16:37) seanf

As with all things WordPress, it turns out there's a plugin (several, in fact). Redirect List adds the 301 or redirects to the MySQL database, the same way WordPress adds pages and posts. (Others include SEO Redirection Plugin, which offers 301/302/307 redirects, and the slightly less sophisticated Quick Page/Post Redirect Plugin.)

It's not clear to me whether using the database will be faster or slower than listing all the 301 redirects in .htaccess. As Ryan said, I may need to test and benchmark to be sure.

permanent link

answered 16 Jul '14, 14:51

PeterA
10431022
accept rate: 14%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×76
×75
×9
×7

question asked: 16 Jul '14, 00:25

question was seen: 6,037 times

last updated: 17 Jul '14, 16:37

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM