Encountering a 404 When Accessing Chinese URLs on the Site
- If the WordPress permalink is set to the post name
%postname%and the title is still in Chinese, accessing it results in a 404. - If the category names and tag names are in Chinese, accessing them results in a 404.
- URLs containing Chinese characters or symbols, etc.

The generated URL cannot be supported because it contains Chinese characters, so a 404 is displayed.
Solution
Go to the wp-includes directory under the site directory and edit the class-wp.php file.
找到$pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : '';
可以直接搜索$_SERVER['PATH_INFO']
将这行的第二个$_SERVER['PATH_INFO']替换为mb_convert_encoding($_SERVER['PATH_INFO'], 'UTF-8', 'GBK')
再找到list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
将$_SERVER['REQUEST_URI']替换为mb_convert_encoding($_SERVER['REQUEST_URI'], 'UTF-8', 'GBK')After performing the above steps, save the file—and now WordPress URLs will support Chinese characters!
All articles on this blog are licensed under CC BY 4.0 unless otherwise stated.
评论
TwikooArtalk