Home >CMS Tutorial >WordPress >How to make WordPress support Chinese URLs
The following column WordPress Tutorial will introduce to you how to make WordPress support Chinese URLs. I hope it will be helpful to friends in need!
I made a fixed link (%postname%) when configuring WordPress, but after that, I accidentally clicked on the Chinese TAG link of the article ( For example, http://yoursite.com/p/tag/ (this is in Chinese) directly gave me a 404 Not Found. This made me very depressed. Not being able to access it normally would affect the user experience of the website. However, after many searches, The cause of the problem was discovered through the data.
Wordpress uses the UTF8 character set. However, the Chinese characters of the URL submitted for URL access are GBK, so the article title is searched based on this GBK string, so it is definitely not found. . . In other words, this GBK string must be converted into UTF8.
Let WordPress support Chinese URLs
After many searches, I finally found out that Chinese URLs can be supported by simply changing the code twice without using a plug-in.
The following is the modification method
Modify the class-wp.php file in the wp-includes directory:
1. Find
_SERVER['PATH_INFO'];
and change it to
_SERVER['PATH_INFO'], 'UTF-8', 'GBK');
2. Find
_SERVER['REQUEST_URI'];
and change it to
_SERVER['REQUEST_URI'], 'UTF-8', 'GBK');
. The above two modifications are both in the function parse_request, wordpress4 There will be some differences between .8 and wordpress4.9.8. I will post a screenshot of my modified code
Let WordPress support Chinese URL
After modification After that, Chinese strings can be supported in WordPress URLs.
The above is the detailed content of How to make WordPress support Chinese URLs. For more information, please follow other related articles on the PHP Chinese website!