Special characters encoding image file names after server migration

I migrated the WordPress website from the Hostgator shared host to the UMPLU stack.

The problem started when I exported image files with special characters, such as a file operários_tarsila-1024x640.jpg.

When WordPress tries to get to the file, it displays an error. I found a reason:

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

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

So, it seems that the difference between the encoding áfrom %C3%A1( ácharacter) to a+ %CC%81(combination of accute accent) is what makes WordPress not display my images.

So, now on my server I have thousands of accented image file names with a character+ structure combining accentand WordPress that calls image file names with a structure accented character.

Is there a bash way to rename all of them using a comparison table? Or a way to make Apache aware of these differences and point to the correct file when such confusion occurs?

+4
source share
4 answers

-, , .

:

  • , ( maluco , ).

  • Filezilla, UTF-8.

> > { } > a > UTF-8

+5

wordpress, FileZilla FileZilla Mac.

Mac OSX CentOS-, , a +% CC% 81.

, apache % C3% A1, Wordpress.

+1

PHP script, Mysql HTML?

PHP: http://php.net/manual/en/function.mb-internal-encoding.php

Mysql: http://php.net/manual/en/function.mysql-set-charset.php

HTML: <meta http-equiv="content-type" content="text/html; charset=utf-8" />

.

, script, , :

function wd_remove_accents($str, $charset='utf-8')
{
    $str = htmlentities($str, ENT_NOQUOTES, $charset);

    $str = preg_replace('#&([A-za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str);
    $str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); // pour les ligatures e.g. '&oelig;'
    $str = preg_replace('#&[^;]+;#', '', $str); // supprime les autres caractères

    return $str;
}

: http://www.weirdog.com/blog/php/supprimer-les-accents-des-caracteres-accentues.html

0

, , ... Wordpress , 404 .

phpMyAdmin. , .

, © .

, . 1-4a rename. ( ). /wp-content/uploads/ .

, . , wp_posts wp_postmeta. SQL, -

update wp_posts set guid = replace(guid,'©','');

UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '©', '') 
WHERE LOWER(RIGHT(meta_value, 5)) = '.jpeg' OR 
LOWER(RIGHT(meta_value, 4)) IN ('.jpg', '.gif', '.png')

, , , .

WP plugin Regenerate Thumbnails, + , .

, ! , -!

0

Source: https://habr.com/ru/post/1613068/


All Articles