IIS Web.Config 301 Rewrite for PHPBB3


If you delete a forum from PHPBB3 and don’t want to hurt your SEO it’s recommended that you put 301 redirects in place so you’re not returning 404s back to the search engines.

When you haven’t got .htaccess files to work with and instead are faced with the daunting task of using web.config files to run on IIS it can be tricky, especially when you’re dealing with a technology that uses query strings and parameters like PHPBB3.

We can address this issue by employing Rewrite Maps that means you can essentially create a simple list of source and target redirects that are sensitive to the query strings and parameters.

By using a 301 redirect you achieve two things.  The first is that it will tell ALL search engines to remove the entry from their database and replace it with the destination and it means that anyone who clicks the link will get redirected to the new content.  .htaccess editing is more of a known quantity and it’s only when you start trying to user the Microsoft IIS web.config approach that issues arise.  Doing simple redirects is easy, but not when the URL’s have query strings or parameters.  This is the reason most people complain that normal redirects or rewrites don’t work with PHPBB3.

Let’s for example, say that in your PHPBB3 forum you delete the following forums:


But then realise that these have already been indexed by Google, or even worse – someone has created a high value link to one of them.

You decide that you want to redirect them to two other relevant forums:


You would use the following code in your web.config file: (double click to select all code for copy/paste)

[sourcecode language=”plain”]
<?xml version="1.0" encoding="UTF-8"?>
<rule name="Redirect Rule 1 for Old Forum">
<match url=".*" />
<add input="{Old Forum:{REQUEST_URI}}" pattern="(.+)" />
<action type="Redirect" url="{C:1}" appendQueryString="false" />
<rewriteMap name="Old Forum">
<add key="/viewforum.php?f=20" value="/viewforum.php?f=40" />
<add key="/viewforum.php?f=21" value="/viewforum.php?f=41" />

The key to this whole process is the rewriteMap element of the web.config.  It allows you to very efficiently list redirects together which means less code and less effort to maintain the file.

You can then test to make sure your 301 redirects are being processed properly by using a site such as those found from this Google search

I hope you’ve enjoyed this post, please feel free to share your thoughts below.


Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.