GetSimple CMS with Microsoft IIS

All the latest news from across the site is available here!

GetSimple CMS with Microsoft IIS

John Stray
November 10th, 2014

Running GetSimple CMS on Microsoft IIS based hosting may not be supported by the developers of the system, but it is possible with not too much work.

Microsoft IIS doesn't support .htaccess files, so we will need to convert our .htaccess files to a format that Microsoft IIS does understand, web.config. The only problem is, Microsoft IIS will only convert URL rewriting sections of .htaccess file which means that we will have to manually setup directory permissions to substitute for .htaccess' DENY and ALLOW directives.

This article will explain in detail how to setup URL rewriting so that Pretty URLs work properly, plus an in depth explanation on how to setup directory permissions to properly control security across your GetSimple CMS domain, and a writeup about how to secure your website with a SSL Certificate and HTTPS.

Pretty URLs in GetSimple CMS is a very handy feature for the benefit of Search Engine Optimisation (SEO) but it's something that requires the use of URL rewriting, a feature that comes natively with Apache based servers and their .htaccess files. Microsoft IIS however, does support URL rewriting, but using a very different type of file with a very different Syntax. For GetSimple CMS, there are two way you can get this to work in Microsoft IIS; Either using the example that I will provide below, or converting your current .htaccess file.

Converting .htaccess files

Converting .htaccess files in Microsoft IIS is not that hard in IIS 7+. To do this, open up the 'Internet Information Services' Console and in the left hand side pane, open up your server, followed by the 'Sites' folder, then click once on your site from the list. This might be, for example, 'Default Website'. Once you've clicked on your website, a collection on icons will appear in the right hand window pane. Look for URL Rewriting and double-click it. The icon should be hiding under the 'IIS' heading. Once on the URL Rewrite page, you want to look for the 'Import Rules...' link under the actions pane on the very right side, or you can right click in an empty space in the list, point to 'Inbound Rules', then select 'Import Rules'. Once on the 'Import mod_rewrite Rules' page, click on the button with the three dots and find the location of your current .htaccess file, then click import. Once done, click apply and your set to go.

Example web.config file

Below is an example web.config file that you can use. Just copy the content below into a new text document, and save it as web.config in the root of your web server. By default, this is located at: 'C:\\inetpub\\wwwroot\\web.config'. The example below will work for a basic GetSimple installation, plus the rule require for the GetSimple Blog plugin. Just change the paths marked in bold as required.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Blog" stopProcessing="true">
                    <match url="(^feed)/([|^post|^tag|^page|^archive|^category]+)/([^/.]+)/?$" ignoreCase="true" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="index.php?id={R:1}&amp;{R:2}={R:3}" appendQueryString="true" />
                </rule>
                <rule name="User Friendly URL scheme" stopProcessing="true">
                    <match url="([^/.]+)/$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?id={R:1}" />
                </rule>
            </rules>
        </rewrite>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

This is some text

Setting up your Microsoft IIS server to use SSL with GetSimple is quite easy. There are two methods you can use; the first is to get a certificate signing request then optain a new certificate, the second is to use an existing certificate.

Installing a Server Certificate

To install a new certificate, first follow the instructions at the first following url, then once you have the certificate, follow the instructions at the second url:

To install an existing certificate that you have for your domain, follow the instructions in the following url:

Configuring Website Settings for SSL

Once you have the certificate(s) installed, you will then need to configure your website to use that certificate. To do this, right click on your website in the left window pane (eg. Default Web Site) and click on the 'Edit Bindings' option. In the dialog that appears, select 'Add...', then in the following dialog, select the following options, then click 'OK', then 'Close':

  • Type: "https"
  • IP address: Internet Facing IP Address (eg. "192.168.0.1")
  • Port: 443
  • SSL certificate: Name of Imported Certificate (eg. "StartCom PFX Certificate")

The next step is to add a rule to your web.config file (That configuration file we talked about earlier). To do this, using a text editor simply add the following rule to your web.config file BEFORE any other rules:

<rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
  <match url="(.*)" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTPS}" pattern="^OFF$" />
  </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>

Configuring GetSimple for SSL

Lastly, you will need to configure your GetSimple installation to use SSL. Follow the very simple instructions here:

How to setup GetSimple on HTTPS/SSL [GetSimple Wiki]

Disabling the Annoying Warning

When using GetSimple CMS on a Microsoft IIS based server, you will get a rather annoying warning saying that it doesn't like it. This is quite simple to disable. Just open up your gsconfig.php file in your favourite text editor and look for the following text, then remove the preceding hash/pound symbol thats sitting before 'define' (on the second line marked in bold in this example).

# Disable check for Apache web server, default false
#define('GSNOAPACHECHECK', true);

That's it your done. No more annoying warning message.