1

i want in wordpress long unlimited with no char limit

i use plugin wordpress seo

when i try make url like

https://sitename.com/برمجة-تصميم-موقع-مركز-رفع-تحميل-تطبيق-تطبيقات-ايفون-اندرويد/ it show only can be

https://sitename.com/برمجة-تصميم-موقع-مركز-رفع-تحميل-تطبيق-ت/

only 39 char can be make it url

so how we can edit this problem and it have problem with google for long url or its ok?

waiting answer and advice

3 Answers 3

4

You might think it's 39 characters long, but it's actually 332 characters long.

This is the real URL you're trying to use:

https://sitename.com/%D8%A8%D8%B1%D9%85%D8%AC%D8%A9-%D8%AA%D8%B5%D9%85%D9%8A%D9%85-%D9%85%D9%88%D9%82%D8%B9-%D9%85%D8%B1%D9%83%D8%B2-%D8%B1%D9%81%D8%B9-%D8%AA%D8%AD%D9%85%D9%8A%D9%84-%D8%AA%D8%B7%D8%A8%D9%8A%D9%82-%D8%AA%D8%B7%D8%A8%D9%8A%D9%82%D8%A7%D8%AA-%D8%A7%D9%8A%D9%81%D9%88%D9%86-%D8%A7%D9%86%D8%AF%D8%B1%D9%88%D9%8A%D8%AF/

But Those Aren't Arabic Characters?!

There's no such thing as a true Arabic URL. HTTP requests don't use unicode, and the RFC that determines a valid URL doesn't include non-latin characters.

Then How Do International URLs Work?

Encoding! Each characters UTF value is percent encoded so it fits into the latin character-set. The browser uses this internally but translates for the address bar and tooltips.

So your URL might look like this to you:

https://sitename.com/برمجة-تصميم-موقع-مركز-رفع-تحميل-تطبيق-ت/

But it's actually:

https://sitename.com/%D8%A8%D8%B1%D9%85%D8%AC%D8%A9-%D8%AA%D8%B5%D9%85%D9%8A%D9%85-%D9%85%D9%88%D9%82%D8%B9-%D9%85%D8%B1%D9%83%D8%B2-%D8%B1%D9%81%D8%B9-%D8%AA%D8%AD%D9%85%D9%8A%D9%84-%D8%AA%D8%B7%D8%A8%D9%8A%D9%82-%D8%AA/

Each percent, e.g. %D8, represents a code for a non-english character. This is equivalent to UTF-8 prior to percent encoding. The browser hides this by displaying the decoded character in its UI so that you can read it, rather than showing the ugly percent encoded version it's really using.

So What's the Maximum URL Length?

The spec doesn't give a maximum, but software might place limits. If it does there's a HTTP code that indicates the URL is too long.

But what about WordPress?

What's The Maximum Post Slug Length?

This will be determined by the size of the column in the posts table. At the time of writing, the post_name column is varchar(200), putting the limit at 200 characters.

Arabic and international post names will be longer than they are written, so multiply the length by 3, which gives a maximum of 66 characters

Can I Increase This Number?

Yes... ish, but at great risk. You can use SQL to manually increase the column size from 200 to a higher value, but when updating WordPress and doing other table operations, WordPress may resize the column back to 200 characters during an upgrade. This would truncate and break all your post slugs and URLs.

Only do this if you're comfortable modifying WordPress Core for every update and security fix. There is no guarantee that WordPress will even use the extra space. If you intend to go down this route, it will be expensive, time consuming, and very easy to break.

Is This Hurting My SEO?

No, Google etc know about this, and handle it fine. But if it did hurt your SEO, it'd hurt every other Arabic site just as much.

WordPress SEO will be counting the characters of the encoded version, not the human readable decoded version, so ignore it and file a bug report with the plugin author

Alternatives

You can back this ticket that's trying to bump the max from 200 to 400 in a future version of WordPress:

https://core.trac.wordpress.org/ticket/10483

2
  • thanks for answer , so to edit 200 varchar it make any problem and how open to all posts in database to be 2000 char?
    – div info
    Commented May 18, 2017 at 21:54
  • Modifying the table schema is not recommended and might cause data loss when updating WordPress when it changes the column size back to 200
    – Tom J Nowell
    Commented May 18, 2017 at 21:56
1

The problem the plugin is reporting doesn't exist. As Tom pointed out the URL contains more bytes than 39, but not more characters.

The part after the domain name is encoded in UTF-8, and every search engine knows how to handle that. That's why you will be found when someone is searching for a word that is part of your visible URL. Punycode is used to encode domain names with non-ASCII characters. That doesn't affect you at all.

Ignore the plugin "warning". It's the result of a bug in that plugin, because it is counting bytes, not characters.

8
  • Copy and paste the URL in the question and you'll get a punycode encoded URL, the page linked to indicates this is the case, percent encoded UTF-8 values
    – Tom J Nowell
    Commented May 18, 2017 at 22:05
  • @TomJNowell Punycode is used for domain names.
    – fuxia
    Commented May 18, 2017 at 22:06
  • What you've said about bytes is still incorrect, they're percent encoded UTF-8 values, if it were bytes then we'd be seeing garbled half byte characters. I've ammended my question to mention UTF-8 percent encoding instead though
    – Tom J Nowell
    Commented May 18, 2017 at 22:08
  • A character is a semantic unit, it may be composed of multiple bytes, that's why UTF-8 is a multibyte encoding. Counting the bytes to determine the characters is just wrong.
    – fuxia
    Commented May 18, 2017 at 22:10
  • these values aren't literally encoded UTF-8 characters, they're percent encoded, the same way url_encode works. Just the same as you can ampersand encode in HTML. These aren't literal UTF-8 encoded bytes, if they were they'd look very different
    – Tom J Nowell
    Commented May 18, 2017 at 22:17
0

Try to add these lines to your theme's functions.php file:

// First of all lets remove standard hook
remove_filter('sanitize_title', 'sanitize_title_with_dashes');

// Add our custom hook for sanitize_title method
add_filter('sanitize_title', 'custom_sanitize_title_with_dashes', 10, 3);

/**
  * Sanitizes a title, replacing whitespace and a few other characters with dashes.
  *
  * Limits the output to alphanumeric characters, underscore (_) and dash (-).
  * Whitespace becomes a dash.
  *
  * @since 1.2.0
  *
  * @param string $title The title to be sanitized.
  * @param string $raw_title Optional. Not used.
  * @param string $context Optional. The operation for which the string is sanitized.
  * @return string The sanitized title.
  */

function custom_sanitize_title_with_dashes($title, $raw_title = '', $context = 'display') {
  $title = strip_tags($title);

  // Preserve escaped octets.
  $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);

  // Remove percent signs that are not part of an octet.
  $title = str_replace('%', '', $title);

  // Restore octets.
  $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);

  if (seems_utf8($title)) {
    if (function_exists('mb_strtolower')) {
      $title = mb_strtolower($title, 'UTF-8');
    }
    $title = utf8_uri_encode($title, 3000);
  }

  $title = strtolower($title);

  if ( 'save' == $context ) {
    // Convert nbsp, ndash and mdash to hyphens
    $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );

    // Convert nbsp, ndash and mdash HTML entities to hyphens
    $title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title );

    // Convert forward slash to hyphen
    $title = str_replace( '/', '-', $title );

    // Strip these characters entirely
    $title = str_replace( array(

      // iexcl and iquest
      '%c2%a1', '%c2%bf',

      // angle quotes
      '%c2%ab', '%c2%bb', '%e2%80%b9', '%e2%80%ba',

      // curly quotes

      '%e2%80%98', '%e2%80%99', '%e2%80%9c', '%e2%80%9d',
      '%e2%80%9a', '%e2%80%9b', '%e2%80%9e', '%e2%80%9f',

      // copy, reg, deg, hellip and trade
      '%c2%a9', '%c2%ae', '%c2%b0', '%e2%80%a6', '%e2%84%a2',

      // acute accents
      '%c2%b4', '%cb%8a', '%cc%81', '%cd%81',

      // grave accent, macron, caron
      '%cc%80', '%cc%84', '%cc%8c',
    ), '', $title );

    // Convert times to x
    $title = str_replace( '%c3%97', 'x', $title );
  }

  $title = preg_replace('/&.+?;/', '', $title); // kill entities
  $title = str_replace('.', '-', $title);
  $title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
  $title = preg_replace('/\s+/', '-', $title);
  $title = preg_replace('|-+|', '-', $title);
  $title = trim($title, '-');

  return $title;
}

Or try this plugin: Longer Permalinks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.