WordPress Permalink changes to question mark (?) in URL

My Permalink custom url is /%post_id%/%postname%/

and my website is in Persian language, for some posts the Permalink is change in URL from

Read More

http://www.ahangbaz.com/1300/%d8%a7%d8%a8%db%8c-%d8%b7%d9%be%d8%b4-%da%86%d8%b4%d9%85%d9%87/
into –>
http://www.ahangbaz.com/1300/?-???-????/

but this doesn’t happen for all post, for e.g following post works fine:
ahangbaz.com/1106/%D9%82%DB%8C%D8%B5%D8%B1-%D8%A8%D8%B9%D8%AF-%DA%86%D9%86%D8%AF-%D8%B3%D8%A7%D9%84/

I checked in wp_posts table of wordpress and Post_name seems similar for both posts.

If I change the post_name to English it works fine but when post_name is in Persian,problem occures. web server is IIS 7.5 on windows 2008 R2.


Further tests:

  • I changed the thema and disabled all plugin, it still happens. I checked DB colation and its UTF8.

  • To reproduce the issue use the post_title = ابی – طپش – چشمه and post_name will be %d8%a7%d8%a8%db%8c-%d8%b7%d9%be%d8%b4-%da%86%d8%b4%d9%85%d9%87

  • The same problem happens with categories when the slug is in Persian ahangbaz.com/category/%d8%a7%d8%a8%db%8c doesn’t work but when its in English or a number it works ahangbaz.com/category/22.

Related posts

Leave a Reply

2 comments

  1. 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'];
    
  2. I don’t have comment capabilities, but the problem is very likely to be on the MS server side, specifically the URL Rewrite module. This is what handles permalinks on IIS. There is a hotfix for this problem, but you should probably apply all the hotfixes available for your system.