Simple Sitemaps for Multisite rewrite rules on IIS server

Hi,

I would like to install sitemap.php into my wp-content folder, but when it comes to the rewrite rules, I'm in a bit of a bind as I'm using an IIS server. This means that I don't have a .htaccess file, but rather a web.config file.

Currently, this is what that the web.config file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WordPress Rule 1" stopProcessing="true">
                    <match url="^index\.php$" ignoreCase="false" />
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 2" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
                </rule>
                <rule name="WordPress Rule 3" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                    <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
                </rule>
                <rule name="WordPress Rule 4" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 5" stopProcessing="true">
                    <match url="(^[_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </rule>
                <rule name="WordPress Rule 6" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </rule>
                <rule name="WordPress Rule 7" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
        <handlers accessPolicy="Read, Execute, Script" />
        <httpProtocol>
            <customHeaders>
                <add name="X-UA-Compatible" value="IE=edge" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>
</configuration>

Where and how do I add the following line? I'm not sure how to change the code to fit with a web.config file.

RewriteRule ^(.*/)?sitemap.xml wp-content/sitemap.php [L]

Much thanks!

  • Vaughan
    • Support/SLS MockingJay

    Hi @chris,

    We don't usually deal with IIS here, most of us are all apache users not IIS.

    fortunately, I might have the solution for you.

    Can you try the following.

    <rule name="rule 1G" stopProcessing="true">
    	<match url="^(.*/)?sitemap.xml"  />
    	<action type="Rewrite" url="/wp-content/sitemap.php"  />
    </rule>

    Hope this helps

  • Chris
    • New Recruit

    That does help, thank you. Another semi-related install question.

    The instructions for installation show removing sitemap.php out of the folder, but the folder it's removing it from is much different than the one that actually gets downloaded.

    The plugin folder now only has three files:
    1. changelog.txt
    2. simple-sitemaps.php
    3. sitemap.php

    If I'm installing on multisite, do I still just drag sitemap.php to wp-content or do I have to install the complete plugin? I'm just verifying since the instructions and the download do not look the same.

    Thanks again.

  • Vaughan
    • Support/SLS MockingJay

    Hi Chris,

    when you added the rule, did you add it in the right location.

    You should add the rule after:

    <rule name="WordPress Rule 2" stopProcessing="true">
                        <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                        <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
                    </rule>

    In your webconfig.

    You'll need to edit the rule.

    So it should look like

    <rule name="WordPress Rule 2" stopProcessing="true">
                        <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                        <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
                    </rule>
    <rule name="WordPress Rule 3" stopProcessing="true">
    	<match url="^(.*/)?sitemap.xml"  />
    	<action type="Rewrite" url="/wp-content/sitemap.php"  />
    </rule>

    Remember you'll need to adjust the Rule numbers for all the rules following.

    So where you have wordpress rule 3 in your web.config you posted, you'll need to change 3 to 4, 4 to 5 & so on.

    the location of the rule makes all the difference.

    As for copying the file, yes you still need to move the sitemap.php into your wp-content/ folder

    I'll flag our docs team, to update the usage guide as it's out of date and the images are no longer valid.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.