rankmath / seo-by-rank-math

Rank Math is a revolutionary WordPress SEO Plugin that combines the features of many SEO tools and lets you multiply your traffic in the easiest way possible :bulb: :chart_with_upwards_trend: →
https://rankmath.com
107 stars 52 forks source link

Encoded category URLs give 404 error when removing category base #18

Closed dawnbirth closed 4 years ago

dawnbirth commented 4 years ago

Describe the bug Category URLs in which category slug is not Latin characters --like Arabic--, open as 404 not found page when the encoded part of the URL --encoded slug-- is converted to uppercase and "Strip Category Base" option is turned on.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new category and make its slug in Arabic charachters.
  2. Add some posts to the newly created category to avoid 404 page due to it's empty.
  3. Go to Rank Math general settings and turn on "Strip Category Base" option.
  4. Open the newly created category link in the browser, it should open without issue.
  5. Copy the category url and convert the encoded part to its uppercase form, paste it again in the browser and visit it, a 404 page appears instead of the category archive page.

Expected behavior

Encoded forms of URLs should work the same when the encoded part is in its uppercase or lowercase form.

balazsrm commented 4 years ago

Hello @dawnbirth

Thank you for reporting this issue, and thanks for the PR as well.

Upon further investigation, it seems that this is a problem in WP core, not in Rank Math. When I create a new category with a slug that has special characters in it (let's say áéíőű, which will be encoded as %C3%A1%C3%A9%C3%AD%C5%91%C5%B1) then example.com/category/áéíőű will correctly open the category archive, however, example.com/category/ÁÉÍŐŰ will NOT, it leads to a 404. This can be confusing because a category with the slug aeiou will open correctly, no matter if we go to example.com/category/aeiou or example.com/category/AEIOU.

This is independent of Rank Math settings, and even of Rank Math being active or not. Because of this, we will probably not merge your PR.

In case we misunderstood the issue, please let us know the exact steps we need to take to reproduce it (including the arabic characters you tried it with, and their uppercase counterparts). Thank you.

dawnbirth commented 4 years ago

Thank you for your reply,

With us, the issue doesn't occur when strip category base is off. Also, we newly migrated from Yoast to Rank Math and we faced this issue before with them and the suggested code edits are actually forked from Yoast SEO. Reference ticket from Yoast: https://github.com/Yoast/wordpress-seo/issues/8183

This issue was also reported by "Ivan Atanasov" on Rank Math support website: https://support.rankmath.com/ticket/problem-with-remove-category-base-feature/

Note: the case sensitivity I'm talking about is the encoded form of the special chars not the special chars in its decoded form.

balazsrm commented 4 years ago

Thank you for the clarification, now I could reproduce the issue. And your PR fixes it. We will probably include the same in an upcoming update.