omega omega - 6 months ago 17
HTML Question

How to fix UTF8 URL?

I have links in an html file like


href="%87%d9%84-%d9%8a%d9%86%d9%81%d8%b9-%d8%a7%d8%ae%d9%84%d9%89-%d8%a8%d8%b1%d9%86%d8%a7%d9%85%d8%ac-%d8%a7%d9%84%d9%85%d9%8a%d8%aa%d8%a7%d8%aa%d8%b1%d9%8a%d8%af-%d9%8a%d9%86%d8%a8%d9%87%d9%86%d9%89/index.html"


And I want when the user clicks on this link in the browser, the link will
be


RealUtf8Text/index.html


Is There any way to use it using
.htaccess
file ?
If not, how we can do it using a javascript file ?

I don't want to make changes in the files, just add .htaccess or javascript file and the problem is solved.

Answer

The problem appears to be that your URL does not contain valid UTF-8 data. There is no UTF-8 sequence that begins with the octet 87.

I'm guessing that your URL is missing a d9 or d8 octet. This URL:

http://localhost/%d9%87%d9%84-%d9%8a%d9%86%d9%81%d8%b9-%d8%a7%d8%ae%d9%84%d9%89-%d8%a8%d8%b1%d9%86%d8%a7%d9%85%d8%ac-%d8%a7%d9%84%d9%85%d9%8a%d8%aa%d8%a7%d8%aa%d8%b1%d9%8a%d8%af-%d9%8a%d9%86%d8%a8%d9%87%d9%86%d9%89/index.html

is shown as arabic characters in my browser:

Browser address bar

How the URL is displayed will of course depend on the browser's support for arabic characters, and is not something that can be affected by JavaScript or .htaccess.