Handle UTF-8 files names in Centos 7 & Apache 2.4

apache-2.4centos7utf-8

My images whose names contain accented letters (é, à etc.) are not accessible via Apache (404 error).

I think it's not related to Apache. I checked the configuration file:

AddDefaultCharset UTF-8

When I connect via Putty, and run the command "ls -la" to list the images, the accented letters are replaced with "?" in the console.

Here's the relevant info that may help:

> echo $LANG
en_US.UTF-8
> cat /etc/environment
empty file
> locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

I found some tutorials, but they are applicable to Centos 5/6.

PS: Renaming files is a possible solution, but not envisageable in my case.

Best Answer

First @Simohammedhttc: You are using correct names! Please do not resort to renaming files. It is the year 2016. We have all the technology available so that nobody has to castrate some filenames just because the names are not English.

The locale settings look fine. The fact that putty has a problem displaying non-ASCII characters (i.e. showing ? instead) might be totally putty's problem. Not using putty these days but I recall playing with the putty settings to get it right.

I just checked that my current CentOS 7 will happily serve this umlaut URL via Apache2:

http://<server>/äöü.txt

The text file contains again the same umlauts. Browser (Safari) says that the encoding is UTF-8. Putting this in some HTML also works:

  • <a href="äöü.txt">äöü.txt</a></td>
  • of course this also: <a href="%c3%a4%c3%b6%c3%bc.txt">äöü.txt</a>

Please try if the images can be accessed directly by pasting the image URL into the address bar of the browser.

If that works please check how the links to the images are generated. Take a look at the source:

  • Verify that the browser recognizes everything as UTF-8.
  • Verify that the image URLs are not mangled by any intermediate processing.
Related Topic