Today, I wanted to take a step back from my normal Web Design tutorial or WordPress tip and share something with you that we’ve found recently, which has proven to be very useful.
I’m sure you’ve all put a website live to take the place of an older website. Now, if your clients old website didn’t have great search rankings or optimisation, you can just put their new website online; in place of the old one.
If your client has spent a lot of money and invested a lot of time in SEO (search engine optimisation) for their previous website, there’s going to be things on there which you don’t want to lose. Search engine rankings are one of these things. It’s not just SEO you want to preserve though, imagine you have a really successful page on your website; this could be a blog post or just a normal page, but statistically, you know it’s bringing in a lot of visitors each month. If users are browsing straight to the page, when you put your new website online—they’ll be redirected to the new website’s 404 page (best case scenario). If you do have any one of these types of pages/posts, I’m going to assume that you’ve taken the time to re-create or copy it across to your new website.
So what we need to do, is tell the search engines; but more importantly, your online visitors, where the new page has gone.
“The Pledge”
What we can use for this is something called a ’301 redirect’. I’ll give a quick overview and example, but for more information, check out my colleague James’ video blog on the topic.
So, a 301 redirect, or 301-status code is used to inform users that an old page on your website has changed URL (whether its a new domain, or just a new page).
A simple example of this is below:
Redirect 301 /old-page.html http://www.mydomain.com/newpage.html
You just add that to your htaccess file and you’re away!
“The Turn”
Here’s where we step it up a notch, things take a turn and get a little more complex.
So, same scenario, but imagine our old page on our website uses query strings, or parameters in the URL to show users different content based on how they reached the page. Statistics may show that these pages bring in most of your websites visits, so you may want to make a bespoke page for each.
The only short-term problem you’ll be faced with is trying to redirect the query strings the same way as a 301 redirect works above—unfortunately, it doesn’t. Luckily, using some htaccess magic you can redirect query strings by using the following format.
So in your htaccess, use:
RewriteCond %{QUERY_STRING} ^id=3
RewriteRule ^index\.php$ /new-page.html? [R=301,L]
For every query string you need to redirect, use the two lines above in your htaccess.
We’re using a rewrite condition and rule. To quickly explain what they do:
- Rewrite Condition – this is what query string to redirect
- Rewrite Rule – this is where to redirect to
You’ll see at the end of the rewrite condition, ‘^id=3$‘.
This is where you need to change the id=3 to whatever your query string is. The character before and after looks for any URL, which contains this parameter.
In the line below, you just same way as before, add in your new page URL. Its important to keep the ‘?‘ at the end of the URL—this removes the query string from the end. If you were to leave it, the old pages query string (id=3), would carry through to the new page; which you don’t want!
“The Prestige”
There you have it, adding these two simple methods in your htaccess will allow you to redirect old pages to new.
You may have a different method to achieve the same result, if you do, please leave a comment below!


