服务器迁移后,图像文件名中的特殊字符编码 [英] Special characters encoding in image filenames after server migration

查看:124
本文介绍了服务器迁移后,图像文件名中的特殊字符编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将WordPress网站从Hostgator共享主机迁移到Ubuntu Digital Ocean LAMP堆栈。

I've migrated a WordPress website from a Hostgator shared host to a Ubuntu Digital Ocean LAMP stack.

当我导出具有特殊字符的图像文件时,麻烦就开始了,例如文件
operários_tarsila-1024x640.jpg

The trouble started when I exported the image files which had special characters, for example the file operários_tarsila-1024x640.jpg.

当WordPress尝试访问该文件时,它会显示错误。我找到了原因:

When WordPress tries to reach the file, it displays an error. I've found the cause:

我可以通过Inspect Element看到Wordpress试图调用的原因: http://mywebsite.com/wp-content/uploads/2013/02/oper%C3%A1rios_tarsila-1024x640.jpg ,服务器返回404错误。

I can see via Inspect Element that Wordpress tries to call: http://mywebsite.com/wp-content/uploads/2013/02/oper%C3%A1rios_tarsila-1024x640.jpg and the server returns a 404 error.

但是,如果我在浏览器中键入以下URL: http://mywebsite.com/wp-content/uploads/2013/02/opera%CC%81rios_tarsila- 1024x640.jpg 它起作用并且显示图像。

However if I type this URL in the browser: http://mywebsite.com/wp-content/uploads/2013/02/opera%CC%81rios_tarsila-1024x640.jpg it works and the image is displayed.

因此,似乎á编码从%C3%A1 á字符)到 a + %CC%81 (结合重音符号)导致WordPress无法显示我的图像。

So, it seems like this difference between the á encoding from %C3%A1 (á character) to a+%CC%81 (combining accute accent) is what is causing WordPress to not display my images.

所以现在我的服务器中有成千上万个带重音符号的图像文件名,结构为 character + 结合重音和WordPress调用图像文件名,结构为重音字符

So now I have in my server thousands of accented image filenames with the structure character+ combining accent and WordPress calling the image filenames with the structure accented character.

bash是否有一种方法可以使用比较表对所有文件进行重命名?还是一种使Apache意识到这些差异并在发生这种混乱时指向正确的文件的方法?

Is there a way bash rename all of them with a comparisson table? Or a way to make Apache aware of those differences and point to the right file when this kind of confusion happen?

推荐答案

显然问题是如何在新服务器上解压缩备份。

Apparently the problem is how the backup is decompressed on the new server.

有两种方法可以解决此问题:

There are 2 ways to fix this:


  1. 使用不带重音的名称手动重命名文件,然后修改数据库并更改数据库中的文件名(这是恶意的,可能很危险,最好备份数据库)。

  1. Rename the files manually by names without accents and then modify the database and change the file names in the database (This maluco and can be dangerous, it would be best to back up the database).

使用Filezilla上传文件,但是将其设置为强制使用UTF-8进行字符集编码。

Upload files using Filezilla, but setting it to force the charset encoding in UTF-8.

文件>站点管理器> {您的站点}>标签字符集>强制UTF-8

File> Site Manager> {YOUR SITE}> Tab Charset> Force UTF-8

这篇关于服务器迁移后,图像文件名中的特殊字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆