5

I recently moved a Wordpress site from one.com to a linux vps server running Ubuntu 16 with Apache. Everything works fine except images with åäö which show as broken, right clicking and copying the link shows the following.

/images/vara-p%C3%A5l%C3%A4st1.jpg

As soon as you paste this in the browser address bar and hit enter it gets turned into

/images/vara-påläst1.jpg

And shows a 404 error. I navigated to /images/ which lists all the files in the directory and I can see that vara-påläst1.jpg is there.

copying the link from the images folder gives me the following

/images/vara-pa%cc%8ala%cc%88st1.jpg

Which resolves to the correct image.

Something is clearly wrong with the filenames and it seems to me like it is an encoding issue. I tried to solve this with convmv -f iso-8859-1 -t utf8 * but it says all files are already UTF-8 encoded and won't update anything.

How can i fix filenames with åäö characters after transferring them from another web host?

5

convmv is right: the filenames are already UTF-8 encoded. I think it's still the right tool to use though.

There is more than one way in Unicode to get the å glyph. The first way is that å (U+00E5) exists as a character on its own, which is how it's encoded in your link.

But you can also take a normal a (U+0061), and add the circle ̊ (U+030A) as a combining character, to get . And something during the migration must have re-encoded your filename from the first representation to the second.

The man page of convmv makes reference to "normalization form C" (used on Linux) and "normalization form D" (used on OS X). From experimentation, it looks like form C represents å as its own character, and form D represents using the combining circle.

Back up your files so you have a known checkpoint if something goes awry, then try the following:

convmv --nfc -f utf8 -t utf8 *

Alternately, you could try the migration again and dodge the re-encoding issue completely.

If you have shell access on the old host, you could create a tar archive of the site (tar czf my_site.tar.gz my_site_directory), then copy the archive to the new host and extract it there (tar xzf my_site.tar.gz). This will shield the filenames from changes as they're now data inside another file.

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.