WordPress Permalink changes to question mark (?) in URL

The problem as @Indolering mentioned is related to URL Rewrite module that the URLs containing UTF-8 characters is not correctly passed when processed by the URL Rewrite module.

Because I’m not the server owner and I’m unable to install the mentioned hotfix (even though I’m using IIS8.5 the problem is still existed) I had to get around this in somehow.

The solution suggested by @pouria-p for Joomla is also applicable to WordPress.

Step 1.
Update the rewrite rule in the web.config file

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
            <rule name="WordPress" patternSyntax="Wildcard">
                <match url="*"/>
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                    </conditions>

                    <!-- The changes are applied to this line only -->
                    <action type="Rewrite" url="index.php" />
            </rule></rules>
    </rewrite>
  </system.webServer>
</configuration>

The rule will be as following :

<action type="Rewrite" url="index.php?requesturi={URL}" />

Step 2. Update the $_SERVER['REQUEST_URI'] manually by adding the following line to the top of the index.php file :

if(isset($_GET['requesturi']))
  $_SERVER['REQUEST_URI'] = $_GET['requesturi'];

Leave a Comment