WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] Unicode Characters in page slug leads to a 404 error on a Network of sites (4 posts)

  1. mike40033
    Member
    Posted 1 year ago #

    Hi!

    I have a network of sites, one site for each language I'm gettinf the site translated into.

    Some of the sites have problems, I think it's because of Unicode characters in page slugs. Oddly, pages without special characters in the URl also have the same problem.

    The site with the problem is at http://www.big-animals.com/pl

    You can find pages using the search box, and there's a page listed in the menu - however, clicking any link to a page produces a 404 error.

    NB the pages were not created via the wordpress interface, but via a script, trying to grab the content that had been auto-translated by the GTS translation plugin.

    mysql_connect(localhost,$usr,$psw);
    mysql_select_db($dbs);
    $result = mysql_query("SET NAMES utf8");
    $sql = "delete from wp_5_posts where 1";
    $res = mysql_query($sql);
    $sql = "select * from wp_gts_translated_posts where language='pl'";
    $res = mysql_query($sql);
    while ($row = mysql_fetch_assoc($res)) {
      $insert = "insert into wp_5_posts ";
      $fields = "(post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_name, post_modified, post_modified_gmt, menu_order, post_type, comment_count)";
      $val = " values ";
      $values = "(1, '" . $row['created_time'] . "', '" . $row['created_time'] . "', '" . addslashes($row['post_body']) . "', '" . addslashes($row['post_title']) . "', '" . $row['post_excerpt'] . "', 'publish', 'open', 'open', '" . addslashes($row['post_slug']) . "', '" . $row['modified_time'] . "', '" . $row['modified_time'] . "', 0, 'page', 0)";
      $sql = $insert . $fields . $val . $values;
    //  print($fields . "\n");
      print('moving ' . $row['post_title'] . ".....\n");
      $result = mysql_query($sql);
      print(mysql_error());
      print("\n");
    }
    
    mysql_close();

    This script worked fine for French, Spanish, Italian, German... but not Polish... See http://www.big-animals.com/fr , for example.

    I've tried the advice at http://semlabs.co.uk/journal/enabling-chinese-arabic-and-other-high-unicode-in-wordpress-slugs to no avail....

    Help! Is there anything else left for me to try?

  2. Kshitij
    Member
    Posted 1 year ago #

    Based on my previous experiences I would suggest a quick workaround.
    1) login to your mysql DB and change the table collation to utf8_general_ci
    2) update the permalink thereafter should do the trick.
    HTH !!

  3. Jumia
    Member
    Posted 11 months ago #

    If the Codex isn't helping, login to your WP admin panel > Settings > Permalinks > Choose the desired structure and click 'Save Changes'.

    This will properly rewrite your .htaccess file.

  4. mike40033
    Member
    Posted 11 months ago #

    Hi all, thanks for your replies...

    The solution I found that worked was simply to urlencode() the post slugs before putting them into the database.

    They appear as legible characters in the WordPress post slug field, and in modern browser URL boxes, but under the covers they're all urlencoded now.

    Unless it was this PLUS some earlier tinkering I thought had not worked.

Topic Closed

This topic has been closed to new replies.

About this Topic