Fixing some Drupal URL issues
I was digging through our analytics the other day, looking for pages that no one visited anymore, and realized that there’s a long tail of pages that shouldn’t be there: pages with uppercase in the path (someone typed lanecc.edu/About, instead of lanecc.edu/about) and pages with trailing slashes (lanecc.edu/about/ vs lanecc.edu/about). Since both of these practices aren’t the best for SEO, I thought it was time we got them fixed.
Redirecting Mixed Case to Lowercase
First I thought I’d tackle this with the magic of mod_rewrite. Instructions looked simple enough. But once that was in my vhost, I discovered there were no more styles on my page, because our CSS/JS aggregator uses mixed case hashes for each aggregate file. It’s possible this is changeable, but when we first launched the site, several thousand documents were uploaded before we installed transliteration. Since each of those could have a mixed case URL, we needed a new fix.
Removing Trailing Slashes
Though it doesn’t matter if we use trailing slashes or no trailing slashes, it’s important we use one or the other. We’re going with no trailing slashes.
The module we put together is available on GitHub. It simply looks for either of the above situations, makes sure the path is a real page, and issues a redirect if appropriate. Now we just need to wait a few weeks for analytics to college new data so we can resume our hunt for ROT.