2

I am trying to create an HTML link to a web page hosted on an Apache server that contains umlauts (in my test case it is ä.html).

So I tried the following in HTML:

<a href='ä.html'>ä.html</a>

<a href='&auml;.html'>&amp;auml;.html</a>

<a href='%C3%A4.html'>%C3%A4.html</a>

and

<a href='%E4.html'>%E4.html</a>

Only the last link fetched the page I intended. The other links gave me a 404.

Of course, I'd rather go with the first two options. Is there a way to configure a directory directive such that this is possible?

Unfortunately, I have no admin rights on the server. I can only change the .htaccess in the directory.

1

Are you sure that <a href='&auml;.html'>&amp;auml;.html</a> doesn't work? It should link to the right document (although the link text will be wrong, as you also encoded the &; the correct way to do this would be <a href='&auml;.html'>&auml;.html</a>).

However, if you just want to use umlaute directly, you can do so by making sure that:

  • You saved your file with a character set that allows umlaute (eg utf8).
  • You specified that character set via <meta charset="[CHARACTER_SET]">.
| improve this answer | |
  • Yes, <a href='&auml;.html'>&auml;.html</a> doesn't work. I have tried with <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> and <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> (and settting the corresponding character set of the html file) – René Nyffenegger Mar 5 '16 at 15:21
  • 1
    In that case, we need more information to help you (it should work the way I described). What character set does your file actually have? In linux, you can check this via file -bi yourfile.html. What is the character set the server sets? You can test this via curl -I http://example.com/yourfile.html, if a character set is set, it will be shown in the content-type header. If it is not the same character set as your file, umlaute will not be shown correctly. You could fix that by changing the character set of your file, or by setting AddDefaultCharset CHARSET in your htaccess. – tim Mar 5 '16 at 15:46
1

A better solution is to never use accented or special characters in URL's as they can case problems with linking.

Best practice is to convert accented characters to the non accented version.

| improve this answer | |
  • This is called transliteration and there is a bunch of libraries you can use for that. Would be my approach as well – Neograph734 Mar 6 '16 at 9:45
  • @Neograph734 and do many CMS /programmers actually use them properly and test all the edge cases properly. My comment is based on experience at Elsiveer to reduce bugs we mandated no use of acented characters – Pepone Mar 6 '16 at 12:42
  • I have no reference on who uses it and how often, I just knew the name of the operation and wanted to leave it here for people who might be searching for this. It is easier to find a transliteration module then a convert special characters into alphabet characters module :) – Neograph734 Mar 6 '16 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.