Further to my posts on WordPress to e107 migration, here is a quick trick for anyone wanting to maintain their ranked pages in the Google search engine.
In this post we look at how to 301 redirect all of our old news.php links to our new site.
Why do We Want to Redirect our Old Posts?
When you change around your URLs you’ll break any incoming links from other sites around the web. In most cases you won’t be in a position to ask the website owner to update the link to your new URL. And if your site has 1000s of links you wouldn’t be able to do this manually anyway!
Because of the value these links have when it comes to boosting your search engine rankings you need to think carefully about preserving the incoming “link juice”. And of course no site wants to show a 404 missing page error to a potential new reader.
Thankfully there is a way to do this without too much loss – welcome to the 301 redirect.
A 301 redirect is the most efficient and Search Engine Friendly method of page redirection. It’s easy to implement and it should preserve your search engine rankings for the page in question. The code “301” is interpreted as “moved permanently”.
Forward e107 News Pages to WordPress Pages
I had a couple of ideas on how to implement this:
- Auto generate an htaccess file with all my old pages forwarded to the new page. This has the advantage that I can plonk all the redirects into the .htaccess and delete e107 from my server. The auto generation would be simple with the right SQL query, however there would be a large number of redirects which wouldn’t make for a clean .htaccess file. Also, I didn’t know what impact this might have on the server performance – anyone know if having a large .htaccess file is a drain on resources?
- Create an e107 plugin that contained an e_MODULE file that can handle the forwarding. The idea is to have e107 and WordPress installed side by side, when someone hits a news.php page the script knows what post we are showing and it knows the title of the news page. It is then straight forward to grab the new WordPress URL from the database and fire off a 301 redirect to that new page.
And it is the latter solution that I implemented. The code is shared here:
Note that this hasn’t been tested all that thoroughly and might not work for every news type link, oh, and you’ll need to update the above to point at your own site!
Hopefully a similar idea will work for the forum if/when I migrate that.