The best way to redirect people is through the internet server using Apache, but that isn’t available unless you have your own server. The next best way is through a .htaccess file, which gives the server instructions on how to handle files. And it is pretty easy to just put a line in this text file saying to redirect anyone who asks for a particular web page to go to the new page. The problem is I have 633 web pages (each blog post).
Actually this isn’t that bad. I have archive pages on both sites that list all the entries and have links. So it isn’t that hard to take the source of those two pages, get rid of the stuff I don’t want, combine the files, and then add the redirect command to each line. Now I have my 633 redirects.
redirect 301 /archives/2011/mcafee.html http://fiveforks.com/ted/2011/12/mcafee/
This is the brute force method. There are more elegant solutions. You can make one statement with wildcards and say anyone who wants a page on the old website can find exactly the same file on the new site. This works well as long as the file names and the paths to the directory are the same at both sites. But that would be too easy. I have my old blog structure set up with all the entries in an archive folder, then subdirectories for the year. However WordPress skips an archive folder and adds an extra subdirectory for the month. Further, the old site has pages ending in .html but the new site just ends in a slash after the post name. I could deal with the archive and the slash with some clever wildcards, but there is no way to get the month. Some people were even able to come up with a way to forward the name of posts with underscores separating the words on their old blog to the dashes between words that WordPress favors (supposedly because Google can separate words with dashes but not words with underscores, and if Google can read the words then it can send people looking for those words to your page).
Jeb’s blog uses a month directory in the path, so he will probably be able to use a blanket statement with wild cards, but meanwhile I could not get even a simple redirect to work. I tried putting a .htaccess file in my archives folder, in the year folder, in the five forks root, and still got nothing.
I went looking for other solutions and found a Movable Type template that would produce a 301 redirect using php. The problem with that is the posts are all html, not php. It is possible to modify htaccess to tell the server to process html files as php files, and I tried that a lot of different ways, but I couldn’t make that work.
So finally I went back and thought about the brute force method some more, and figured the htaccess file should really be on the root of mac.fiveforks.com and not just fiveforks.com. I looked up the properties for the mac5 subdomain to get the correct directory and found a blank htaccess file there. I put one redirect in there as a test and it worked fine. So the answer was in front of me all along, I was just in the wrong place. I put my big text file of redirects and, after some tweaks, got it working just fine for every entry.
It could be that I could get the html/php thing to work by modifying the correct htaccess file (now that I know where it is), but I don’t know if there is a point now that I have what I want. There could be some slowdown on the server as it reads through the 633-line htaccess file every time someone gets a file from Mac5, but the redirects aren’t forever, just until Google figures it all out.