Search code examples
.htaccessutf-8internationalizationidn

Redirect to URL with umlauts or accents via .htaccess


To redirect to a new URL that contains diacritics via .htaccess, what is the correct and safe way?

  • Can I somehow set the .htaccess file to UTF-8 and just use the non-ASCII characters, e.g.:
    redirect 301 / http://www.bücher.ch/

  • Need I use the ACE string instead, e.g.:
    redirect 301 / http://www.xn--bcher-kva.ch/

  • Is urlencode the way to go? I tried the following without success:
    redirect 301 / http://www.b%C3%BCcher.ch/

For context, the following page on internationalized domain names (IDN) has a section about the technical solution to include accents and umlauts in domains.


Solution

  • In the domain part, you must use ASCII Compatible Encoding (ACE). In the rest of the URL, you use urlencode. So, in .htaccess…

    http://www.bücher.ch/schöne/

    …needs to be written as…

    http://www.xn--bcher-kva.ch/sch%C3%B6ne/