Proper web.config for MyBB on a Windows Server

If you want to host MyBB on a Windows Server with IIS instead of a Linux server with Apache, you’ll need a web.config file instead of a .htaccess file for seo-friendly URLs. Windows Servers are often used in intranet solutions and MyBB can extend intranets very well.

This is a sample web.config file content for MyBB, you might need to adjust the paths if you don’t place the file in your MyBB root.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <httpErrors existingResponse="PassThrough" />
    <rewrite>
      <rules>
        <rule name="Rule 1" stopProcessing="true">
          <match url="^forum-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="forumdisplay.php?fid={R:1}" appendQueryString="true" />
        </rule>
        <rule name="Rule 2" stopProcessing="true">
          <match url="^forum-([0-9]+)-page-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="forumdisplay.php?fid={R:1}&amp;page={R:2}" appendQueryString="true" />
        </rule>
        <rule name="Rule 3" stopProcessing="true">
          <match url="^thread-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="showthread.php?tid={R:1}" appendQueryString="true" />
        </rule>
        <rule name="Rule 4" stopProcessing="true">
          <match url="^thread-([0-9]+)-page-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="showthread.php?tid={R:1}&amp;page={R:2}" appendQueryString="true" />
        </rule>
        <rule name="Rule 5" stopProcessing="true">
          <match url="^thread-([0-9]+)-lastpost\.html$" ignoreCase="false" />
          <action type="Rewrite" url="showthread.php?tid={R:1}&amp;action=lastpost" appendQueryString="true" />
        </rule>
        <rule name="Rule 6" stopProcessing="true">
          <match url="^thread-([0-9]+)-nextnewest\.html$" ignoreCase="false" />
          <action type="Rewrite" url="showthread.php?tid={R:1}&amp;action=nextnewest" appendQueryString="true" />
        </rule>
        <rule name="Rule 7" stopProcessing="true">
          <match url="^thread-([0-9]+)-nextoldest\.html$" ignoreCase="false" />
          <action type="Rewrite" url="showthread.php?tid={R:1}&amp;action=nextoldest" appendQueryString="true" />
        </rule>
        <rule name="Rule 8" stopProcessing="true">
          <match url="^thread-([0-9]+)-newpost\.html$" ignoreCase="false" />
          <action type="Rewrite" url="showthread.php?tid={R:1}&amp;action=newpost" appendQueryString="true" />
        </rule>
        <rule name="Rule 9" stopProcessing="true">
          <match url="^thread-([0-9]+)-post-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="showthread.php?tid={R:1}&amp;pid={R:2}" appendQueryString="true" />
        </rule>
        <rule name="Rule 10" stopProcessing="true">
          <match url="^post-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="showthread.php?pid={R:1}" appendQueryString="true" />
        </rule>
        <rule name="Rule 11" stopProcessing="true">
          <match url="^announcement-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="announcements.php?aid={R:1}" appendQueryString="true" />
        </rule>
        <rule name="Rule 12" stopProcessing="true">
          <match url="^user-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="member.php?action=profile&amp;uid={R:1}" appendQueryString="true" />
        </rule>
        <rule name="Rule 13" stopProcessing="true">
          <match url="^calendar-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="calendar.php?calendar={R:1}" appendQueryString="true" />
        </rule>
        <rule name="Rule 14" stopProcessing="true">
          <match url="^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="calendar.php?calendar={R:1}&amp;year={R:2}&amp;month={R:3}" appendQueryString="true" />
        </rule>
        <rule name="Rule 15" stopProcessing="true">
          <match url="^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="calendar.php?action=dayview&amp;calendar={R:1}&amp;year={R:2}&amp;month={R:3}&amp;day={R:4}" appendQueryString="true" />
        </rule>
        <rule name="Rule 16" stopProcessing="true">
          <match url="^calendar-([0-9]+)-week-(n?[0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="calendar.php?action=weekview&amp;calendar={R:1}&amp;week={R:2}" appendQueryString="true" />
        </rule>
        <rule name="Rule 17" stopProcessing="true">
          <match url="^event-([0-9]+)\.html$" ignoreCase="false" />
          <action type="Rewrite" url="calendar.php?action=event&amp;eid={R:1}" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Note that this will also push PHP errors to your MyBB with the httpErrors line. Otherwise, you’d get a 500 internal server error and not the useful MyBB errors with proper formatting.

You can now use your MyBB on a Windows Server without any issues. Use MyBB for Business!

Leave a Reply

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