开发者

UTF-8 characters in friendly URLs

I have made a website in modx revolution php framework and recently I hav开发者_JAVA百科e added Friendly Url functionality in apache.

As the site is in Greek I would like to have greek characters in the url, is it a valid approach for friendly urls or it can cause a problem in the future?

edit: Example Links from the japanese wikipedia ディートリヒ・ブクステフーデ


Section 2.2 of the the RFC 1738 document states that:

Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
reserved characters used for their reserved purposes may be used
unencoded within a URL.

You can encode other characters in your URL, and some browsers (e.g. Chrome) will often decode them in the address bar.

However, to ensure the URL is readable on all browsers you should avoid using the greek characters altogether in your URL - use a US-ASCII equivalent if possible.


It's not a very good idea. Either urlencode the non-ASCII charaters (but that won't be very url-friendly) or convert them to their ASCII counterparts.

$url = $server . $path . '/' . urlencode($greektext);

-

$arr1 = array('Α', 'α', 'Β', 'β', ...);
$arr2 = array('A', 'a', 'B', 'b', ...);
$url = $server . $path . '/' . str_replace($arr1, $arr2, $subject);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜