Home > CMS Tutorial > WordPress > How to make WordPress support Chinese URLs

How to make WordPress support Chinese URLs

藏色散人
Release: 2019-09-28 11:59:50
forward
3600 people have browsed it

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!

How to make WordPress support Chinese URLs

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.

How to make WordPress support Chinese URLs

The following is the modification method

Modify the class-wp.php file in the wp-includes directory:

1. Find

_SERVER['PATH_INFO'];
Copy after login

and change it to

_SERVER['PATH_INFO'], 'UTF-8', 'GBK');
Copy after login

2. Find

_SERVER['REQUEST_URI'];
Copy after login

and change it to

_SERVER['REQUEST_URI'], 'UTF-8', 'GBK');
Copy after login

. 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

How to make WordPress support Chinese URLs

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!

Related labels:
source:aliyun.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template