Skip to content

Instantly share code, notes, and snippets.

@eduncan911
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduncan911/9864466 to your computer and use it in GitHub Desktop.
Save eduncan911/9864466 to your computer and use it in GitHub Desktop.
web.config configuration for redirects for MyBB w/Google SEO plugin on IIS 8 and Windows Azure Web Sites
<?xml version="1.0" encoding="UTF-8"?>
<!--
version 1.0
to use, make sure to change the following:
1) replace "www.MyDomain.com/forum/" with the actual url of your site. Such
as "www.acmecorp.com/" or "www.acmecorp.com/forum/".
2) if you change the urls here, make sure they match your Google SEO Url
settings exactly.
3) place this web.config in the root directory of your forums. if your root
directory is /forum/, then place it there. if it is at the root of your
domain, such as www.acmecorp.com/, then place it there.
Known issues:
* this does not capture /forum/index.php to rewrite to just "/forum/".
technically, Google will see two pages as your homepage: one with
/forum/index.php, and one without it. this can cause a penalty
in Google rankings. i'll tweak it when I get a chance.
-->
<configuration>
<system.webServer>
<rewrite>
<rules>
<!--
change this to the exact url you want. for example, below we enforce
the "www" prefix for all urls. if there is no "www", it will redirect
to have "www" prefixed.
you can remove this if you want. it just forces the www.
-->
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.MyDomain\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.MyDomain.com/{R:1}" />
</rule>
<!-- these rules below are the normal imported ones -->
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^([^&amp;]*)&amp;(.*)$" ignoreCase="false" />
<action type="Redirect" url="http://www.MyDomain.com/forum/{R:1}?{R:2}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^sitemap-([^./]+)\.xml$" />
<action type="Rewrite" url="misc.php?google_seo_sitemap={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^Forum-([^./]+)$" />
<action type="Rewrite" url="forumdisplay.php?google_seo_forum={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 4" stopProcessing="true">
<match url="^Thread-([^./]+)$" />
<action type="Rewrite" url="showthread.php?google_seo_thread={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 5" stopProcessing="true">
<match url="^Announcement-([^./]+)$" />
<action type="Rewrite" url="announcements.php?google_seo_announcement={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 6" stopProcessing="true">
<match url="^User-([^./]+)$" />
<action type="Rewrite" url="member.php?action=profile&amp;google_seo_user={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 7" stopProcessing="true">
<match url="^Calendar-([^./]+)$" />
<action type="Rewrite" url="calendar.php?google_seo_calendar={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 8" stopProcessing="true">
<match url="^Event-([^./]+)$" />
<action type="Rewrite" url="calendar.php?action=event&amp;google_seo_event={R:1}" appendQueryString="true" />
</rule>
<!-- These rules below are for the built-in MyBB Friendly Urls feature. -->
<rule name="Imported Rule 9" stopProcessing="true">
<match url="^forum-([0-9]+)\.html$" ignoreCase="false" />
<action type="Rewrite" url="forumdisplay.php?fid={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 10" 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="Imported Rule 11" stopProcessing="true">
<match url="^thread-([0-9]+)\.html$" ignoreCase="false" />
<action type="Rewrite" url="showthread.php?tid={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 12" 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="Imported Rule 13" 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="Imported Rule 14" 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="Imported Rule 15" 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="Imported Rule 16" 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="Imported Rule 17" 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="Imported Rule 18" stopProcessing="true">
<match url="^post-([0-9]+)\.html$" ignoreCase="false" />
<action type="Rewrite" url="showthread.php?pid={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 19" stopProcessing="true">
<match url="^announcement-([0-9]+)\.html$" ignoreCase="false" />
<action type="Rewrite" url="announcements.php?aid={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 20" 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="Imported Rule 21" stopProcessing="true">
<match url="^calendar-([0-9]+)\.html$" ignoreCase="false" />
<action type="Rewrite" url="calendar.php?calendar={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 22" stopProcessing="true">
<match url="^calendar-([0-9]+)-year-([0-9]+)\.html$" ignoreCase="false" />
<action type="Rewrite" url="calendar.php?action=yearview&amp;calendar={R:1}&amp;year={R:2}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 23" 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="Imported Rule 24" 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="Imported Rule 25" 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="Imported Rule 26" 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>
@eduncan911
Copy link
Author

I only have 1 outstanding issue and that is capturing /forum/index.php and redirecting it to just /forum/. I haven't gotten around to that yet. I'll wait until Google complains about the duplicate url issue - if it detects it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment