Enabling Clean URLs on IIS Installations
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
Comments
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.Thank you so much! Exactly what i was looking for.
Not found issue.
I have pi.php file in wwwroot folder. I want to run it as domain.com/pi
I have set $Configuration['Garden']['RewriteUrls'] to true and following code in web.config:
<rule name="PI Test">
<match url="pi" />
<action type="Rewrite" url="pi.php" />
</rule>
But, it still doesn't work. Any help is much appreciated.