Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

In this Discussion

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Enabling Clean URLs on IIS Installations

ShadowdareShadowdare π Moderator
edited August 2014 in Tutorials

If you use IIS on Windows to host your Vanilla forum and would like to enable clean URLs, then follow these steps below.

Be sure to install the IIS Rewrite module first.

Try finding this line in Vanilla's /conf/config.php file. If it doesn't exist, add the line.

$Configuration['Garden']['RewriteUrls']

Set the setting to true. The line should look like $Configuration['Garden']['RewriteUrls'] = true;.

Next, in your website's Web.config file, add a rewrite section so that the file looks like this. You might have other sections in the file, but the important part is to have the rewrite block within the system.webServer section:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
          <rules>
            <rule name="Vanilla Rule 1" stopProcessing="true">
              <match url="^(.*)$" ignoreCase="false" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php\?p={R:1}" appendQueryString="true" />
            </rule>
          </rules>
        </rewrite>
    </system.webServer>
</configuration>

Known bug with IIS and RewriteURLs: discussion names with many unicode characters in the URL cause a not found error.

For Vanilla forums installed in sub-folders, you may have to tweak the rewrite rule to make it work. If anyone has any experience with doing so, please leave a comment below and let us know how you made it work.

Add Pages to Vanilla with the Basic Pages app | Publish articles with the Articles app

anycrafthgtonight

Comments

  • Matt2kMatt2k New
    edited May 20

    To use this in a subfolder, you only need to add a "<clear />" tag. This removes any existing rewrite rules that might be inherited from parent folders.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <clear />
            <rule name="Vanilla Rule 1" stopProcessing="true">
              <match url="^(.*)$" ignoreCase="false" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php\?p={R:1}" appendQueryString="true" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    
  • Thank you so much! Exactly what i was looking for.

Sign In or Register to comment.