Jump to content

Non latin chacters in friendly URL


Recommended Posts

How can I display non-latin characters in friendly URLs? In my case thai letters.


This should be quite easy using url encoding.


For example, thai word for "shoe":



with url encoding it's:



But prestashop filters out the % character and the result is:




I've looked around on thai websites with thai letters in the URL. The HTML source contain url encoded characters such as the example above.


Example of such page:


Link to comment
Share on other sites

I've just tried to add url-encoded string into link_rewrite manually thru phpMyAdmin and it WORKS! =)


However, it does NOT work if I enter thai letter. It works only if I enter url encoded.


Here is the result:



In the address bar it shows thai letters.

Edited by alfa123 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

To be able to input Thai letters in products, there are 3 steps:

Step 1

FIle#1: classes/Validate.php

Change from

public static function isLinkRewrite($link)
return preg_match('/^[_a-zA-Z0-9\-\pL]+$/u', $link);


public static function isLinkRewrite($link)
  return preg_match('/^[_a-zA-Z0-9ก-๙\-\pL]+$/u', $link);


Step 2

File #2: shop_root/js/admin.js, at the very beginning of the file, look for function str2url(str,encoding,ucfirst)

Change from

str = str.replace(/[^a-z0-9\s\'\:\/\[\]-]\\u00A1-\\uFFFF/g,'');


str = str.replace(/[^a-z0-9ก-๙\s\'\:\/\[\]-]\\u00A1-\\uFFFF/g,'');


Now we can enter Thai characters in Catalog > Products > SEO > Friendly URL.


Step 3

Finally, I guess .htaccess need to be changed (try messing around [_a-zA-Z0-9-]), but unfortunately I could not get it working. Still looking for a better solution.

Link to comment
Share on other sites

Got it working, there are only 2 files need to be changed:

1. classes/Validate.php

Search for:

return preg_match('/^[_a-zA-Z0-9\-\pL]+$/u', $link);

Replace with

return preg_match('/^[_a-zA-Z0-9\-\pL\pM]+$/u', $link);



2. classes/Dispatcher.php

Search for /pL, and replace with /pL/pM


Then we can input Thai and display the nice friendly URL. It turns out to be quite easy, credit must be given to the Prestashop team for delivering us such a wonderful system.


This is for v1.5.0.15

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...