Website overhaul – part 1a, link redirection

Moving to a completely WordPress-driven site has many benefits but a minor downside is that the WordPress pages that replace my previous static pages now have different URLs. For example the “About me” page used to have the URL but now has the URL To prevent frustration for those literally tens of people who might’ve bookmarked or linked to my website, I needed to put redirects in place. The easiest way to do so would be to create short pages that immediately re-directed people’s web-browsers to a new address using a meta refresh tag (tutorial here). However, this isn’t an ideal solution as it creates an extra step that both slows things down and causes confusion when someone uses their browser’s back function. I.e. the process to get to the page is: click a link/bookmark > receive redirection page > go to new page, so one step back is always the redirection page that then moves you forward again to the new page (and so on ad infinitum).

A much more elegant solution is to do the redirection server-side. In laypersons’ terms, the server recognises the old URL but sends back the new page and the URL in your web browser remains the same. No more back problems, and your site visitors can merrily continue to use their old links. If your website is hosted using the Apache webserver you can use its mod_rewrite function to accomplish this (good beginners guide here). However my web host uses a commercial variant of Apache, the Zeus webserver that does not allow mod_rewrite functionality. There is instead another scripting language that Zeus uses that will enable me to do much the same thing as mod_rewrite. After much poking around for advice I found several articles on how to do this but none of them gave examples basic enough for what I was after. So I made some educated guesses and worked it out. For the benefit of others in a similar situation, here’s what I did. Create a new text file in the root directory of your website called rewrite.script (note there’s no other filename extensions such as .xml or .html after this). Edit this file to contain these lines for as many redirects as you need:

match URL into $ with ^/[pagename].[extension]$
if matched then set URL = [newURL]

Replacing [pagename], [extension] and [newURL] as appropriate. You’ll need the character wherever in the URL there is a full stop to prevent the server from mis-interpretting it. So, for my example above the lines are:

match URL into $ with ^/aboutme.php$
if matched then set URL =/?page_id=2

A very basic solution in the grand scheme of things and I’m sure there are more polished ways of doing it but, if you need more, I’m sure the previous links will point you in the right direction.

2 thoughts on “Website overhaul – part 1a, link redirection

Leave a Reply

Your email address will not be published. Required fields are marked *