Main Content

If you have a spelling mistake in your URL / page name

Archive - Originally posted on "The Horse's Mouth" - 2009-03-21 09:43:26 - Graham Ellis

What do I do if someone reports a spelling mistake on one of our pages? I check that they're right (OK - I usually know straight away that they ARE as I'm one of the world's worst spellers and often distort one word into another valid word), and fix the page. And drop them a brief "thank you" of course. It's actually a help to us to correct even quite small goofs - helps our huge web site look more professional, and the changes indicate to search engines that they're not just indexing a decaying archive.

But what if a spelling mistake extends to the URL? To correct or not to correct?

If there are links to the page, especially external ones (Q - how can you tell ... - you can't be sure, but your combined web log gives you a clue), or if it's been indexed by the search engines and is popular (Q - how can you tell ... A - same as previous answer), you don't want to loose the URL, nor do you want it to survive unmodified as the current / used link. So along comes - once again - our "superhero" - mod_rewrite.

Mod_rewrite can be used to rewrite the faulty location to the correct one, and you can place the page at the correct location. Or you could leave the page where it is, and use mod_rewrite to create a new URL for it. Perhaps better would be to relocate the page, and send out a "moved permanently" message to the browser - that's a return status 301.

The particular example that I had this a.m. related to my corruption of the name Pennines into Penines, in our "share" directory. The directory already has a .htaccess file, already has mod_rewrite enabled, so the extra line I added to do the "301" divert was:

RewriteRule ^penines\.(.*)$ /share/pennines. [R=301,L]

Oh - and I moved the page ;-)

Try it out: penines.html (wrong) link and pennines.html (right) link