WordPress + Xenforo rewrite rules on IIS 7.5

Status
Not open for further replies.

Blandt

OMG Member
Joined
Oct 7, 2010
Messages
51
This configuration assumes that you have xenforo nested inside Wordpress in a folder named community : (please edit)

c:\www\domain\wordpress\community so the URL is like so : www.domain.com ----> Wordpress
and www.domain.com/community ------> Xenforo

So the idea is to set an application inside Wordpress to point to xenforo and we need 2 web.config files. the first located at the root of Wordpress and the second at the root of xenforo.

Here we go:
This is the Wordpress web.config : and please note that I have added a canonical rule to redirect domain.com to www.domain.com If you don't want it please remove that one rule. And also have setup support@domain.com to use your local SMTP server (again edit as appropriate)


Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>

    <defaultDocument>
      <files>
        <clear />
        <add value="index.php" />
      </files>
    </defaultDocument>
    <rewrite>
      <rules>
        <rule name="CanonicalHostNameRule1">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
          </conditions>
          <action type="Redirect" url="http://www.domain.com/{R:1}" />
        </rule>
        <rule name="WordPress Rule" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php/{R:1}" />
        </rule>
      </rules>
      <outboundRules>
        <preConditions>
          <preCondition name="ResponseIsHtml1">
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
          </preCondition>
        </preConditions>
      </outboundRules>
    </rewrite>
  </system.webServer>
  <system.net>
    <mailSettings>
      <smtp from="support@domain.com">
        <network host="localhost" />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>

This is Xenforo web.config .. and it goes in the community folder within Wordpress where xenforo files are located :

Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <clear />
        <rule name="CanonicalHostNameRule1">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
          </conditions>
          <action type="Redirect" url="http://www.domain.com/{R:1}" />
        </rule>
        <rule name="XenForo Rule 1" stopProcessing="true">
          <match url="^.*$" />
          <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
          </conditions>
          <action type="None" />
        </rule>
        <rule name="XenForo Rule 2" stopProcessing="true">
          <match url="^(data|js|styles|install)" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
          <action type="None" />
        </rule>
        <rule name="Xenforo Rule 3" stopProcessing="true">
          <match url="^.*$" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
          <action type="Rewrite" url="index.php" />
        </rule>
        <rule name="Xenforo Rule 4" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Ok that's it :) ... Let me know if you need any special setup ... oh and make sure you have the URL rewrite module installed
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,101
Ah, awesome! Thank you for taking the time to publish it here. I poked my friend earlier about this - and I am sure he will go have a looksy.
 
Status
Not open for further replies.
Top