One of the common problems in blogs or websites built by WordPress is that the Chinese tag link does not exist. Google Administrator Tool prompt grabs 404 errors. In particular, windows hosts often have Chinese tag link grabbing errors, and Chinese tags cannot be displayed normally. Or Chinese tags can be displayed normally, but 404 errors will appear after clicking the link, which brings great inconvenience to users and is extremely difficult It greatly reduces the friendliness of the website.
How to solve this problem?
First method:
Open WP include/ classes.php (before 3.1) or WP include/class- wp.php (after 3.1 +, hereinafter referred to as the new version) find line 154 (the new version is line 142)
$pathinfo = $_ SERVER['PATH_ INFO';
Replace with:
$pathinfo = mb_ convert_ encoding($_ SERVER['PATH_ INFO'], 'UTF-8', 'GBK');
Find line 159 (the new version is line 147)
$req_ uri = $_ SERVER['REQUEST_ URI'];
Replace with:
$req_ uri = mb_ convert_ encoding($_ SERVER['REQUEST_ URI'], 'UTF-8', 'GBK');
After my personal test, this method can be used, the new version of the statement may be different from the above, but the method is basically the same, the corresponding statement can be replaced.
Second method:
1. Found in the WP includes folder at the root of the site“ rewrite.php ”This document;
2. Back it up“ rewrite.php ”In case of error (we’d better back up the original code before changing the code);
3. Open“ rewrite.php ”We find the following code in the file:
function get_tag_permastruct() { if (isset($this->tag_structure)) { return $this->tag_structure; } if (empty($this->permalink_structure)) { //Change this line $this->tag_structure = ''; return false; } if (empty($this->tag_base)) $this->tag_structure = $this->front . 'tag/'; else$this->tag_structure = $this->tag_base . '/'; $this->tag_structure .= '%tag%'; return $this->tag_structure; }
4. Put some of them together
" if (empty($this->permalink_structure)) { ”
Amend to read
“ if (! empty($this->permalink_structure)) { ";
Note that there is only a “!” sign in English. After testing, this method is very effective. PS. didn’t find the code in this file directly…
The third method: the final solution to the Chinese tag 404 error is actually ISAPI_ Rewrite pseudo static rules are not well written, which leads to the failure to find the web page file. In fact, just change the rules: the previous tag pseudo static rules
RewriteRule /tag/(.*)$ /index\.php\?tag=$1
Changed rules
RewriteRule /tag/(.*)/$ /index\.php\?tag=$1
I didn’t test this method, so I can’t guarantee its availability. Please back it up before modification!
Third method:
If the above two methods are not feasible, we recommend another method: alias each tag.
Alias is another URL friendly name. It is usually lowercase and can only contain letters, numbers and hyphens.
But for blogs with more than 100 Chinese tags, this method has a huge workload. Use with caution.
This method can link English tags normally, but it works for websites with Chinese tag problems, but it doesn’t work for websites with 404 English tag links.
Read More:
- TP5 fuzzy Chinese characters error [How to Solve]
- [Solved] WordPress Upgrade PHP 5.6 to 7.x Fatal error: Uncaught Error: Call to undefined function mysql_connect()
- [PHP]json_encode Chinese JSON_UNESCAPED_UNICODE returns null in php5.3
- Unserialize(): cause analysis and solution of error at offset
- PHP encryption 3DES error Call to undefined function: mcrypt_module_open() solution
- Laravel-admin php artisan admin:install error reporting problem solution
- [Solved] Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path:
- PHP: How to parse MHT file into HTML
- php Error: mail() Failed to connect to mailserver at “localhost” port 25
- [WordPress Error] Fatal error undefined function is_network_admin()
- Undefined index: name error in composer [How to Solve]
- [Solved] PHP getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL
- How to solve Magento 500 internal server errors
- [PHP] Solve Call-time pass-by-reference has been removed
- [Solved] PHP Fatal error: Uncaught Error: Class ‘Redis‘ not found in
- Using $this when not in object context in (How to Fix)
- Workman Run Error: stream_socket_server() has been disabled for security reasons
- php_network_getaddresses: getaddrinfo failed (How to Fix)
- How to Solve PHP Fatal error: Namespace declaration statement has to be the very first statement
- nginx.conf php-fpm.conf and php.ini Error among the three_ Differences and relations between log instructions