Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of making WordPress support Chinese URL

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to let WordPress support Chinese URL, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Below by the WordPress tutorial column to introduce you to let WordPress support Chinese URL method, hope to help friends in need!

Before configuring WordPress, I made a fixed link (% postname%), but after that, I inadvertently clicked on the link to the Chinese TAG of the article (for example, http://yoursite.com/p/tag/ this is in Chinese) and directly gave me a 404 Not Found. I was very depressed, ah, not being able to visit normally will affect the user experience of the site, but I found the cause of the problem only after searching for information from many parties.

Wordpress due to the use of the UTF8 character set. But the Chinese character of URL submitted by URL access is GBK, so look up the article title according to the string of this GBK, so it must not be found. That means converting the GBK string to UTF8.

Let WordPress support Chinese URL

After multi-party search, I finally know that you only need to change the code twice to support Chinese URL without plug-ins.

The following is the method of modification

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

1. Find

_ SERVER ['PATH_INFO']

Modify to

_ SERVER ['PATH_INFO'],' UTF-8', 'GBK')

2. Find

_ SERVER ['REQUEST_URI']

Modify to

_ SERVER ['REQUEST_URI'],' UTF-8', 'GBK')

The above two changes are in the function parse_request. There will be some differences between wordpress4.8 and wordpress4.9.8. I'll put up a screenshot of my modified code.

Let WordPress support Chinese URL

After modification, Chinese strings can be supported in WordPress URL.

The above is all the content of the method of making WordPress support Chinese URL. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report