Yeah, .htaccess this!

Oof. My brain is largely mush at this moment, thanks to a battle spanning 2 days with the evil, nasty mod_rewrite function in my hosting environment. This site is hosted in a subdirectory with several others, also in subdirectories, running under other technologies (dotNetNuke and Drupal, plus some random static html). For a long time now, I have used a javascript to redirect the domains for those sites — with an annoying lag — to the proper URLs for access. I’ve long wanted a better solution.

I got my chance when I moved that Drupal site from another environment, where it lived at the hosting account root, to its subdirectory of my site. With some changes in configuration, Drupal coped just fine with all its own back-end functions and serving pages. But lots of images had been added, fashionistas being who they are, along with a bunch of PDF files representing portfolio products and other documents. The links and image calls were created back when the site was at the root, and the paths specified then lacked the subdirectory where the site now lives, ergo broken links. Lots of them — way too many to update by hand. And that would be a tacky way to solve the problem anyway. We can do better, I told myself.

A little research turned up promising reports of using a file called .htaccess to both handle the domain redirects and bounce those calls to images and other files to the new URLs under the Drupal installation subdirectory. Now, 2 days later, after probably 11 solid hours of rtfm and consulting my ISP’s support people, I *think* I have it all working. (And all reports I saw included warnings that mod_rewrite is a persnickety beast, complex and disinclined to tolerate even tiny variance.) The Drupal site’s wonderful and attractive owner (yes, I’m biased) will need to double-check that all of her content is now accessible, but I think it’s done.

So the lesson for today is either (a) perseverance furthers or (b) I really need a minion for this stuff, possibly some combination. But at least I can say I waded through the swamp of mod_rewrite and emerged, rather thoroughly muddied but victorious, on the other side.