Search code examples
.htaccessurlutf-8urlencodepercent-encoding

URL percent encoding is not working


I'm trying to do a somewhat simple thing with no luck - I want to display Hebrew/Arabic characters in my URL.

For example: I want the URL to display a file named: aאm.php

So I've percent encoded the middle UTF8 characters and the result is: a%D7%90m.php. I've uploaded a%D7%90m.php to my server (Apache) and tried to request the pages www.example.com/a%D7%90m.php & www.example.com/aאm.php but my server responded:

The requested URL /a%D7%90m.php was not found on this server.

So I tried to upload aאm.php (without the percent encoding) instead, but again no luck when browsing www.example.com/a%D7%90m.php & www.example.com/aאm.php.

How to fix this issue?


Solution

  • The solution was to set a mod rewrite the .htaccess in www.example.com. For example, if you want your link to be www.example.com/عربية and file www.example.com/arabic.php to actually handle the request behind the scenes, then simply write this code in the .htaccess file:

    RewriteEngine 
    OnRewriteRule ^عربية$ arabic.php