| 
 | 
 
 
                        
现在换用了 ISAPI_Rewrite 3.x 发现编码后的字符会变成乱码,如果直接使用中文不编码,则会被格式化为GBK字符串。 
因为 ISAPI_Rewrite 默认是以 UTF-8 的编码接收的。 
解决方案是 
翻了手册,发现有一个配置参数可以解决该问题: 
nounicode|NU 
If NU flag is set, transformation from Unicode to UTF-8 will not take place and all Unicode characters remain encoded in %xx format. 
nounicode|NU 
如果标志设置,从Unicode转换为UTF-8不会发生,所有的Unicode字符编码为%xx的保持格式 
在你的RewriteRule 规则后台添加 NU 即可恢复正常。 
关于ISAPI_Rewrite中文变乱码解决方法,无论何种情况,统一解决思想: 
1、在传输URL时,将中文进行urlencode,这样是没错的。 
2、如果是ISAPI_Rewrite 3.x 只需添加 NU 参数即可。 
配置举例: 
传递的URL地址: 
http://www. 
seecpu.cn 
/sell/search-htm-kw-%C6%BD%B0%E5%B5%E7%C4%D4.html 
原来相应的RewriteRule为: 
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2 
修正后的规则是: 
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2 [NU]  
shopex原规则为: 
RewriteBase / 
RewriteCond %{REQUEST_FILENAME} \.(html|xml|json|htm|php|php2|php3|php4|php5|phtml|pwml|inc|asp|aspx|ascx|jsp|cfm|cfc|pl|cgi|shtml|shtm|phtm|xml)$ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 [ 
[color=]L] 
  
修改后的规则为: 
RewriteBase / 
RewriteCond %{REQUEST_FILENAME} \.(html|xml|json|htm|php|php2|php3|php4|php5|phtml|pwml|inc|asp|aspx|ascx|jsp|cfm|cfc|pl|cgi|shtml|shtm|phtm|xml)$ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 [NU,L] 
这样修改后shopex开启伪静态后就可以搜索中文了,并不会出现乱码现象。也可以正常对搜索结果翻页。 
请看演示站 http://shopex.158558.cn  
  
 |   
 
 
 
 |