Install Config Wiki

All about installing, configuring and troubleshooting

User Tools

Site Tools


suggested_web_config_file_wordpress_iis_server

This is an old revision of the document!


Suggested web.config for WordPress on IIS

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <clear />
                <rule name="WordPress Rule" 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" />
                </rule>
            </rules>
            <outboundRules>
                <clear />
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

Credit to Todd Miller of Dayton Ohio. Screen name “Toddses” See Git Hub Gist: https://gist.github.com/Toddses/7f3729ddf7c6466bb3dc

Todd's Comments: Note the line <action type=“Rewrite” url=“index.php” /> is key. The rule I found through official WP channels suggests using url=“index.php?page_id={R:0}” but this was flawed. Any post that began with a number would return a 404 error.

Following is the above-code as the web.config file may be modified automatically by IIS in the event that you configured IIS Handler Mapping for a specific website to introduce a FastCgi module executable for PHP upgrade, let's say, from PHP7 to PHP 8. The default of the web server is configured for PHP7, but the specific added FastCGI Module for PHP8 executable is auto inserted in the Web.Config file in order to override the PHP7 FastCGI default setting.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <clear />
                <rule name="WordPress Rule" 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" />
                </rule>
            </rules>
            <outboundRules>
                <clear />
            </outboundRules>
        </rewrite>
            <handlers>
                 <add name="PHP8_1" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\php_8_1\php-cgi.exe" resourceType="File" />
            </handlers>
    </system.webServer>
</configuration>
suggested_web_config_file_wordpress_iis_server.1696261578.txt.gz · Last modified: 2023/10/02 15:46 by wikiadmin