XF 2.1 Rewrite rule in web.config format

webbouk

Well-known member
As it stands at the moment my forum files are hosted in a Windows Server which doesn't read .htaccess files, using web.config files instead, unless Rewrite rules are written directly into IIS

My question is how can I acheive this Rewrite rule:
RewriteRule ^forums/(.*)?$ /$1 [R=301,L]

In a format that is acceptable to a web.config file ?

What I am trying to achieve is to move the forum files into the root of my website but to maintain any previous links such as bookmarks, etc, that will continue to point to the present /forums/ directory

Thanks in advance
 
I don't use IIS but based on this you should be able to write or import them.


 
Excellent Brogan, the second link explained how to do it

For the benefit of anyone who might need it:


Code:
                <rule name="Redirect forum links" stopProcessing="true">
                    <match url="^forums/(.*)?$" ignoreCase="false" />
                    <action type="Redirect" url="/{R:1}" redirectType="Permanent" />
                </rule>

Another handy rule is the Fully Friendly URL rule.....

Code:
    <rule name="FullFriendlyURL" stopProcessing="false">
      <match url="." />
      <conditions>
        <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" />
    </rule>


Combining the two so that you can use Full friendly URLs and divert links from a previous /forum directory to the forum after it has been moved to the web root....

Code:
<rewrite>
  <rules>
    <rule name="FullFriendlyURL" stopProcessing="false">
      <match url="." />
      <conditions>
        <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" />
    </rule>
                <rule name="Redirect forum links" stopProcessing="true">
                    <match url="^forums/(.*)?$" ignoreCase="false" />
                    <action type="Redirect" url="/{R:1}" redirectType="Permanent" />
                </rule>
  </rules>
</rewrite>
 
Top Bottom