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 |
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. answered 16 Jul '14, 06:31 ryans ♦♦ 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. answered 16 Jul '14, 14:51 PeterA |