Home > CMS Tutorial > WordPress > Windows IIS 7.5 WordPress pseudo-static Chinese link 404 error solution

Windows IIS 7.5 WordPress pseudo-static Chinese link 404 error solution

藏色散人
Release: 2019-10-11 11:26:21
forward
2250 people have browsed it

Windows IIS 7.5 WordPress pseudo-static Chinese link 404 error solution

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.

Windows IIS 7.5 WordPress pseudo-static Chinese link 404 error solution

First, we create a new "index2.php" file in the WordPress installation directory with the following content:

<?php
// IIS Mod-Rewrite
if (isset($_SERVER[&#39;HTTP_X_ORIGINAL_URL&#39;])) {
    $_SERVER[&#39;REQUEST_URI&#39;] = $_SERVER[&#39;HTTP_X_ORIGINAL_URL&#39;];
}
// IIS Isapi_Rewrite
else if (isset($_SERVER[&#39;HTTP_X_REWRITE_URL&#39;])) {
    $_SERVER[&#39;REQUEST_URI&#39;] = $_SERVER[&#39;HTTP_X_REWRITE_URL&#39;];
} else {
    // Use ORIG_PATH_INFO if there is no PATH_INFO
    if ( !isset($_SERVER[&#39;PATH_INFO&#39;]) && isset($_SERVER[&#39;ORIG_PATH_INFO&#39;]) )
        $_SERVER[&#39;PATH_INFO&#39;] = $_SERVER[&#39;ORIG_PATH_INFO&#39;];
// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
    if ( isset($_SERVER[&#39;PATH_INFO&#39;]) ) {
        if ( $_SERVER[&#39;PATH_INFO&#39;] == $_SERVER[&#39;SCRIPT_NAME&#39;] )
            $_SERVER[&#39;REQUEST_URI&#39;] = $_SERVER[&#39;PATH_INFO&#39;];
        else
            $_SERVER[&#39;REQUEST_URI&#39;] = $_SERVER[&#39;SCRIPT_NAME&#39;] . $_SERVER[&#39;PATH_INFO&#39;];
    }
    // Append the query string if it exists and isn&#39;t null
    if (isset($_SERVER[&#39;QUERY_STRING&#39;]) && !empty($_SERVER[&#39;QUERY_STRING&#39;])) {
        $_SERVER[&#39;REQUEST_URI&#39;] .= &#39;?&#39; . $_SERVER[&#39;QUERY_STRING&#39;];
    }
}
require("index.php");
?>
Copy after login

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>
Copy after login

The effect is as follows:

Windows IIS 7.5 WordPress pseudo-static Chinese link 404 error solution

If WordPress is not installed in the root directory, you need Change "" to "". If the default tag prefix and category prefix (tag and category) are changed in the fixed link settings, just change the corresponding content in this sentence.

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 in the picture above to

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!

Related labels:
source:wpcom
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template