Problem with cyrillic characters in friendly url

前端 未结 3 1509
旧巷少年郎
旧巷少年郎 2021-01-21 09:53

Here\'s the thing. I have friendly urls like

http://site.com/blog/read/мъдростта-на-вековете

http://site.com/blog/read/green-apple

相关标签:
3条回答
  • 2021-01-21 10:14

    Actually, Firefox is cheating you here: the URL actually is url-encoded, but is shown as if it wasn't. So copy-pasting and retrieving it on the server will have the URL encoded.

    (Not sure if other browsers behave in the same way.)

    0 讨论(0)
  • 2021-01-21 10:32

    The above answers are ok, but if you want to use routing with cyrillic it isn't enough. For example if you have http://site.com/блог/статия/мъдростта-на-вековете you will have to do something like this:

    In config/routes.php: $route['блог/статия/(:any)'] = "blog/article/$1";

    In system/core/URI.php , in the function _explode_segments(), you can change

    $val = trim($this->_filter_uri($val));
    

    to

    $val = urldecode(trim($this->_filter_uri($val)));
    

    This will solve the above problem plus controllers and functions.

    0 讨论(0)
  • 2021-01-21 10:37

    The text is just being encoded to fit the specification for URLs.

    Echo out the data to a log to see what you are actually trying to pass to the database.

    You should be able to decode it with urldecode.

    0 讨论(0)
提交回复
热议问题