Skip to content

IIS server config

Robert Isoski edited this page Nov 10, 2019 · 10 revisions

1. Make sure URL rewrite is installed and enabled

Available at: https://www.iis.net/downloads/microsoft/url-rewrite

2. Make sure the "extension=openssl" is enabled

Stack Overflow answer: https://stackoverflow.com/questions/13921458/how-to-enable-openssl-support-in-xampp#answers-header

3. Make sure there's a certificate installed on the server

To ensure the theme/plugin installing works: https://stackoverflow.com/questions/14987857/what-exactly-is-cacert-pem-for

Download the https://curl.haxx.se/ca/cacert.pem file and save it somewhere.

update php.ini -- add curl.cainfo = "PATH_TO/cacert.pem"

4. Apply the following rules to your web.config

If you have other configs in your web.config, you can simply copy/paste the specific <rules> and not the whole block of code.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="rule block browse database">
                    <match url="database.js" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="/-" />
                </rule>
                <rule name="rule block browse cache">
                    <match url="cache.json" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="/-" />
                </rule>
                <rule name="Allow plugin" stopProcessing="true">
                    <match url="plugins/" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Allow jpg" stopProcessing="true">
                    <match url=".jpg" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Allow png" stopProcessing="true">
                    <match url=".png" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Allow gif" stopProcessing="true">
                    <match url=".gif" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Allow txt" stopProcessing="true">
                    <match url=".txt" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Allow doc" stopProcessing="true">
                    <match url=".doc" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Allow pdf" stopProcessing="true">
                    <match url=".pdf" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Allow zip" stopProcessing="true">
                    <match url=".zip" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Allow rar" stopProcessing="true">
                    <match url=".rar" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Allow svg" stopProcessing="true">
                    <match url=".svg" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="rule 1S" stopProcessing="true">
                    <match url="^(.+)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="/index.php?page={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

NOTE: The code above is required to deny access to database.js, cache.json and create clean URL's which are SEO friendly.

It also allows for some formats to be uploaded.

The code above replicates Apache's htaccess functionality with the power of your IIS web.config (server config file). Since IIS doesn't have the "traditional" htaccess file, this is necessary to make WonderCMS work properly.


Clone this wiki locally