phpBB: Redirect broken links after uninstalling an SEO mod


SEO mods beautify your URLs and make them more spider friendly. But what happens when you uninstall an SEO mod? These SEOed URLs becomes broken and return an error code of ‘404 Not Found’. And these obsolete links can be very harmful for your Search Engine Results Page(SERP) rankings.

I’ve got emails from concerned phpBB forum administrators saying that their position in the SERPs have taken a dip after they had uninstalled their SEO mods and used my phpBB robots.txt duplicate indexing fix. What they need to do is redirect these broken links to the vanilla phpBB links. Using some simple rewrite rules, we can redirect those broken links to their proper place. And we’ll return a ‘301 Permanently Moved’ header so that the threads eventually recover their pagerank and SERP positions.
I’ll be using dcz’s Advanced phpBB3 SEO mod Rewrite as an example. This rewrites the URLs as follows :
[sourcecode language=”text”]viewforum.php?f=XX => any-keywords-fXX.html
viewforum.php?f=XX&start=YY => any-keywords-fXX-YY.html
viewtopic.php?f=XX&t=YY => any-keywords-fXX/topic-title-tYY.html
viewtopic.php?f=XX&t=YY&start=ZZ => any-keywords-fXX/topic-title-tYY-ZZ.html
viewtopic.php?p=XX => postXX.html
memberlist.php?mode=viewprofile&u=XX => memberXX.html[/sourcecode]

To redirect the broken/obsolete URLs, you need to add the following piece of code to your .htaccess file at the root of the forum :
[sourcecode language=”text”]Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^[^/.]+-f([0-9]+).html?$ /viewforum.php?f=$1 [R=301,L]
RewriteRule ^[^/.]+-f([0-9]+)-([0-9]+).html?$ /viewforum.php?f=$1&start=$2 [R=301,L]
RewriteRule ^[^/.]+-f([0-9]+)/[^/.]+-t([0-9]+).html?$ /viewtopic.php?f=$1&t=$2 [R=301,L]
RewriteRule ^[^/.]+-f([0-9]+)/[^/.]+-t([0-9]+)-([0-9]+).html?$ /viewtopic.php?f=$1&t=$2&start=$3 [R=301,L]
RewriteRule ^post([0-9]+).html?$ /viewtopic.php?p=$1 [R=301,L]
RewriteRule ^member([0-9]+).html?$ /memberlist.php?mode=viewprofile&u=$1 [R=301,L][/sourcecode]

These rules will ensure that those SEOed URLs are 301 redirected to the proper phpBB vanilla URLs, and you’ll eventually recover your pagerank and SERP position.

If you have a problem or you need mod_rewrite rules for another variant of an SEO mod, leave a comment and I’ll help you.