Skip to content

Instantly share code, notes, and snippets.

@Toddses
Last active July 14, 2023 04:29
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save Toddses/7f3729ddf7c6466bb3dc to your computer and use it in GitHub Desktop.
Save Toddses/7f3729ddf7c6466bb3dc to your computer and use it in GitHub Desktop.
Example 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>
@Toddses
Copy link
Author

Toddses commented Feb 3, 2015

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.

@shakirmengrani
Copy link

Awesome!! it's really helpful for me

@deshabhishek007
Copy link

Thanks, Todd! it worked like Charm.

@newmediacrew
Copy link

Hi Todd,

We have 0 experience with Windows IIS, and this did the job for fixing the permalinks. Thanks for that !

@TrezRayanCo
Copy link

Thank you

@hsankala
Copy link

Thanks

@Amritmatti
Copy link

I don't have much knowledge about Windows. I was working from last 2 days but no luck. Thanks @Toddses you saved my time. It's working :)

@Satyam506
Copy link

Satyam506 commented May 30, 2021

Thanks man 👍

@gcbourque
Copy link

gcbourque commented Jan 31, 2022

The gift that keeps on giving!
NOTE: A web.config file is include with the WordPress-provided IIS version .zip file. IT DOES NOT WORK. But the file provided by Toddses above DOES WORK.

@unsapdev
Copy link

thanks work 10000%

@moifore
Copy link

moifore commented Nov 25, 2022

Thanks, man, for helping to make the internet a better place. This code saved me a lot. Wish I could buy you coffee

@onlylhf
Copy link

onlylhf commented Nov 30, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment