Percent-escapes in URL converted to latin charset on IIS 8.5

After migrating to a new Windows IIS 8.5 server requests are not passed through as UTF-8 characters but single byte latin characters.

UTF-8 characters are needed in order to use pretty or SEO friendly URL’s on our WordPress and Joomla installations.

Read More

From PHP a $_SERVER['REQUEST_URI'] looks like this

/ p r e s s e / p r  ø  v e s i d e
2f7072657373652f7072 f8 766573696465

In the web.config file in the web server root we have

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <appSettings>
      <add key="aspnet:UseLegacyRequestUrlGeneration" value="true" />
   </appSettings>
   <system.web>
      <globalization
         requestEncoding="utf-8"
         responseEncoding="utf-8"
         culture="da-DK"
         uiCulture="da-DK" />
   </system.web>
   <system.webServer>
   ...
   <system.webServer>
<configuration>

Related posts

Leave a Reply

1 comment

  1. Applying the following change to the registry fixed the problem

    reg add HKEY_LOCAL_MACHINESystemCurrentControlSetServicesw3svcParameters /v FastCGIUtf8ServerVariables /t REG_MULTI_SZ /d REQUEST_URIPATH_INFO
    

    Seems the Microsoft KB2277918 hot-fix from IIS 7.5 is rolled into IIS 8.5

    After applying the registry changes $_SERVER['REQUEST_URI'] looks like this in PHP

    / p r e s s e / p r  Ã ¸  v e s i d e
    2f7072657373652f7072 c3b8 766573696465
    

    The bytes C3 B8 being the danish letter ‘ø’.