For WordPress website building, although we have always recommended users to use the Linux system, it is inevitable that many users will still choose the Windows system for various reasons, and users often encounter To solve the problem of 404 errors in Chinese links, the WordPress Tutorial column now provides a solution to the 404 errors in Chinese links (such as tab pages) under Windows IIS 7.5.
First, we create a new "index2.php" file in the WordPress installation directory with the following content:
<?php // IIS Mod-Rewrite if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; } // IIS Isapi_Rewrite else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; } else { // Use ORIG_PATH_INFO if there is no PATH_INFO if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) ) $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) if ( isset($_SERVER['PATH_INFO']) ) { if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; else $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; } // Append the query string if it exists and isn't null if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } require("index.php"); ?>
Then create a new file in web.config Add a rule and place this rule at the top of the rule collection:
<rule name="ChineseURL" stopProcessing="true"> <match url="/(tag|category)/(.*)" /> <action type="Rewrite" url="index2.php" /> </rule>
The effect is as follows:
If WordPress is not installed in the root directory, you need Change "
The above method only applies to Chinese links in tags and categories. If you need to convert all Chinese links on the website (such as articles, pages, etc.), you do not need to add the last step of the web.config rule. Just edit web.config directly and change Since this method is to create a new index2.php file and implement it with pseudo-static rules, it is not affected by WordPress updates and upgrades and is recommended.
The above is the detailed content of Windows IIS 7.5 WordPress pseudo-static Chinese link 404 error solution. For more information, please follow other related articles on the PHP Chinese website!