Renaming files on the entire site….
Earlier today, I implemented a neat tool: mt-refsearch, which looks at the referer that directs people to this site and does something with that info – hi-lights the search info. You can check it out here and choose the fourth link (the one to my site). The problem with that is that it’s a PHP script, so I had to have it load as a PHP script. Since pretty much the entire site is setup as server-parsed HTML files, that didn’t work.
My choices: don’t bother, or rename just about every file on the site. I really liked the idea of adding this script to my site, so suddenly I was faced with re-arranging most of the site. Not cool.
The biggest problem this brings up is search engines – they would all be linking to the old files, which won’t help things. The last thing I wanted (aside from a missing sidebar, which was also due to this re-arranging) was to then make all the links into the site stop working. What to do?
Initially I worried about rebuilding the whole site with the new code – that only took a few minutes to do. I had to rebuild all the pages (1500+ last I checked), so while that was going on, I started to dig for help. I know that you can use a .htaccess file to redirect things – I’ve moved other parts of the site with out disruption this way – but I wasn’t sure how to pull off redirecting such a huge chunk of the site – pretty much everything in the /archives directory needed to stop looking at the .shtml file and look for a .php file. My initial search (“htaccess redirect wildcard“) looked promising, but didn’t work out too well – none of the suggestions actually worked for me.
Then I turned to ProNet, which is a mailing list of other MovableType users. I was led first to mamamusings: redirection solution, and then to Weblogging for Poets: weblog Links: Part 2 — Re-weaving the Broken Web. The second link contains much of the htaccess code I had tried and not been able to use, but between the two of them, I was able to take some heavy lifting off my shoulders – creating a new index page, for example, that had the full path to the file complete with the new path to the file. I could then do some simple find/replaces to make it match the format I needed, then paste the whole thing into my htaccess file.
I’m a little worried about all those redirects in my top-level htaccess file, so I’m considering moving them, but I’m going to watch things for a few days. Because I’ve coded things up right from the start (I hope), I should only need to keep them in the htaccess file for a couple of weeks, until the search engines pick up that the filenames have change:
Redirect permanent /archives/2006/10/18/parenting_chronicles_moved.shtml http://adam.gerstein.net/archives/2006/10/18/parenting_chronicles_moved.php
Hopefully I’ll be able to figure out how to get my wildcard search to work at some point, but I’m not overly worried – the stuff that’s in there is what I need for older entries, and newer entries will be taken care of automatically by the search engines (since they already have the new filenames).
Hopefully, this info will assist someone else who’s having similar troubles somewhere down the line. Or come in handy for me when I forget about all of this in about 2 days.





