how to support UTF8 (japanese, arabic, spanish, …) URL's in PHP

前端 未结 4 950
既然无缘
既然无缘 2020-12-15 14:32

For a web application, we need to link to some user generated content. A users types in a title for e.g. a product and we generate an SEO friendly url for that product:

4条回答
  •  既然无缘
    2020-12-15 15:16

    You're in trouble I'm afraid. The encoding of the URL is at the discretion of the browser. I've encountered the same problem when trying to support URLs with Norwegian special characters and its simply not consistently possible.

    You may be able to redirect a browser to the UTF-8 URL, but it might reply to you in ISO. It gets even worse in some cases where browsers (firefox for instance) will mix ISO and UTF-8 formatting in the same url (this happens particularly with get parameters).

    My suggestion is simply; Don't do it, use either English (better SEO too!) or spell it phonetically.

提交回复
热议问题