0

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.

1
  • that's URL encoding, not UTF-8.
    – Simba
    Jun 25, 2015 at 16:19

2 Answers 2

0

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.

0
0

You use urldecode,

urldecode("%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")

see the documentation in http://php.net/manual/en/function.urldecode.php.
also make sure you have this on your html

<meta http-equiv="Content-type" content="text/html; charset=utf-8"> 
2
  • it is possible using .htaccess or javascript ?
    – omega
    Jun 25, 2015 at 12:28
  • yes. <script> function myFunction() { var uri = "http%3A%2F%2Fw3schools.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab"; var res = decodeURIComponent(uri); } </script> Jun 25, 2015 at 12:47

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.