Web.config for hosting WordPress on IIS


to Developers Blog

I have been playing (a lot) with WordPress on IIS (Windows Server 2019) lately. Nick has been very helpful by guiding me around. WordPress is some kind of an application in the end as long as you stay away from performance-killing plugins.

Even though IIS is not the recommended host for WordPress, it does the job. And the stronger your specs, the better. I get very good results on a very basic AWS Cloud Server with 8GB of RAM on 2 CPU's. 

The web.config below is all you need to:

  1. Have a recent version of PHP working (PHP 8.3.11 in the example below) for all PHP files
  2. Add the one and only static file handler for all other files. 
  3. Have index.php as your (only) default document
  4. Have a rewriting rule to mimic the unsupported .htaccess
  5. Note that this web.config does not deal with any MicroSoft technology (.NET or Classic ASP).

Here it is:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
  <handlers>
<clear />
           <add name="php-8.3.11" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files\PHP\v8311blank\php-cgi.exe" resourceType="Either" requireAccess="Script" />
 
            <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read"/>
 
    </handlers>
    <defaultDocument>
      <files>
        <clear/>
        <add value="index.php"/>
     
      </files>
    </defaultDocument>
    <rewrite>
      <rules>
<rule name="WordPress on IIS" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<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>
    </rewrite>
  </system.webServer>
</configuration>
to Developers Blog

© QuickerSite webCMS 2024

backtotop