Poltergeist diagnosed

Warning: Dork factor 9. It has to be a high dork factor, because this is about bloody htaccess files and mod_rewrite. Every web developer who has dared to dabble in mod_rewrite knows that it’s a black art, and unless you really know what you’re doing it is fantastically easy to break a website, sometimes impressively (infinite loops, yo). It’s the tech version of bubble, bubble, toil and trouble. But I’ve had no choice. I had to go there. Eventually you always have to, if you’re serious about messing about with websites.

Still, it’s been really rough, and many of my trips into htaccess have come to a bad end. Several failures really pushed my “dafuq?” button hard: things that I really (no, really) should have been able to get to work, but could not, or I only got them working with compromises and contortions that seemed freakish.

Today I found the asshole ghost in the machine.

Mod_rewrite is hard, but it isn’t that hard, and I’m not surprised to discover an actual explanation for the prolongued weirdness. Today I had an htaccess-y problem that simply had to be solved. For a solid hour I banged my head against this suspiciously strange failure. Specifically, I needed a 301 redirect to go away, but it just would not. The strangeness was too glaring to dismiss, and the repair was essential. It was so weird that — lightbulb — it was almost like there was another htaccess file issuing contradictory orders. I went digging, and sure enough, I found a duplicate of my htaccess file at the root level of the server. That long set of server instructions, similar-but-different to the real ones, had been sitting there over-ruling me for … about a year, based on the rogue file’s last modification date.

It’s actually amazing the chaos wasn’t much worse.