Redirection of URLs with non-latin characters

69 views Asked by At

I'm having trouble with what seems like a simple redirects, but the separate online tests I've done show interesting results.

URL 1 to redirect:

https://example.com/bg/%D0%B0%D0%B2%D1%82%D0%BE%D1%80/author-name

Note: %D0%B0%D0%B2%D1%82%D0%BE%D1%80 is author (автор) in Bulgarian language.

Rewrite rule:

RewriteRule ^bg/%D0%B0%D0%B2%D1%82%D0%BE%D1%80/(.*)$ https://example.com/bg/author/$1 [L,R=301]

Redirects to:

https://example.com/bg/автор/author-name

Instead, I want it to redirect to:

https://example.com/bg/author/author-name

Test online: https://htaccess.madewithlove.com?share=98002622-055d-4656-9100-32bc297a42c8

URL 2 to redirect:

https://example.com/bg/%25D0%25B0%25D0%25B2%25D1%2582%25D0%25BE%25D1%2580/author-name

Note: %D0%B0%D0%B2%D1%82%D0%BE%D1%80 is probably also author (автор) in Bulgarian language.

Rewrite rule:

RewriteRule ^bg/%25D0%25B0%25D0%25B2%25D1%2582%25D0%25BE%25D1%2580/(.*)$ https://example.com/bg/author/$1 [L,R=301]

Redirects to:

https://example.com/bg/%D0%B0%D0%B2%D1%82%D0%BE%D1%80/author-name

I want it to redirect to:

https://example.com/bg/author/author-name

Test online: https://htaccess.madewithlove.com?share=66fdb0d9-f5bb-45a7-a60c-24accb924410

I tried to separate URL 1/URL 2 and their rewrite rules in two online tests to be easier to understand, (I will need both URLs to redirect on production site).

All I can see is that part of URL in rewrite rule from first example appears in output URL in second example, even if used in separate tests, like I did. It looks like there is some redirection I am not aware of (higher power) witch redirects between:

%D0%B0%D0%B2%D1%82%D0%BE%D1%80
автор
%25D0%25B0%25D0%25B2%25D1%2582%25D0%25BE%25D1%2580

Can anyone fix my redirect rules, if there is anything wrong with them?

1

There are 1 answers

0
Advanced SEO On BEST ANSWER

Problem is in URL decoding. When /%25D0%25B0%25D0%25B2%25D1%2582%25D0%25BE%25D1%2580/ is decoded it becomes /%D0%B0%D0%B2%D1%82%D0%BE%D1%80/, which is also decoded and finally becomes /автор/.

URL redirection rule is needed for each case (to achieve successful redirection without redirect chains):

RewriteRule ^bg/%25D0%25B0%25D0%25B2%25D1%2582%25D0%25BE%25D1%2580/(.*)$ https://example.com/bg/author/$1 [L,R=301]
RewriteRule ^bg/%D0%B0%D0%B2%D1%82%D0%BE%D1%80/(.*)$ https://example.com/bg/author/$1 [L,R=301]
RewriteRule ^bg/автор/(.*)$ https://example.com/bg/author/$1 [L,R=301]