发布:2023/12/7 15:51:49作者:大数据 来源:大数据 浏览次数:717
首先需要在网站根目录下新建web.config,代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="wordpress" patternSyntax="Wildcard"> <match url="*"/> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> </conditions> <action type="Rewrite" url="index.php"/> </rule> </rules> </rewrite> <staticContent> <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff"/> <mimeMap fileExtension=".woff" mimeType="application/x-font-woff"/> </staticContent> </system.webServer> </configuration> |
tag中文显示不正常或分类分页显示不正常
解决办法:安装插件
插件代码如下,在\wp-content\plugins新建目录chinese_tag_names,在此目录新建文件chinese_tag_names.php
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<?php add_action('parse_request', 'coco_chinese_tag_names_parse_request'); add_filter('get_pagenum_link', 'coco_chinese_tag_names_get_pagenum_link'); function coco_chinese_convencoding($str, $to = 'UTF-8', $from = 'GBK') { if (function_exists('mb_convert_encoding')) { $str = mb_convert_encoding($str, $to, $from); } else if (function_exists('iconv')) { $str = iconv($from, $to . "//IGNORE", $str); } $str=rtrim($str, "/");//去掉末尾多余的/ return $str; } function coco_chinese_tag_names_parse_request($obj) { if ($obj->did_permalink == false) return; if(isset($obj->request)) $obj->request = coco_chinese_convencoding($obj->request, get_option('blog_charset')); if(isset($obj->query_vars)) foreach ($obj->query_vars as $key => &$value) { if ($key == 's') continue; $value = coco_chinese_convencoding($value, get_option('blog_charset')); } } function coco_chinese_tag_names_get_pagenum_link($result) { $result = coco_chinese_convencoding($result, get_option('blog_charset')); return $result; } ?> |
另一种办法通过修改代码实现:
wp-includes文件夹下class-wp.php主要看加粗部分
查找代码isset( $_SERVER['PATH_INFO'] )
对应代码修改如下:有两处已经加粗
$pathinfo = isset( $_SERVER['PATH_INFO'] ) ? mb_convert_encoding($_SERVER['PATH_INFO'], "UTF-8", "GBK") : '';
list( $pathinfo ) = explode( '?', $pathinfo );
$pathinfo = str_replace( "%", "%25", $pathinfo );
list( $req_uri ) = explode( '?', mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK") );
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4