【目的】实现网站伪静态设置,带中文参数
事实上Apache伪静态正则表达式并不能识中文,我的页面如(https://blog_cn.cn/index.html?type=某类型&page=1),携带两个参数。
解决办法只有将中文转码后写入,(并且得两次转换)。
【操作流程】
开启Apache相关模块,Apache安装目录下打开/conf/httpd.conf 文件,查找AllowOverride None,替换为 AllowOverride All
在网站根目录下建立.htaccess文件,内写入如下内容。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ([0-9]+)_([a-zA-Z0-9_%]+)?$ index.php?page=$1&type=$2 [L]
</IfModule>
重启Apache服务器。
这个字符串中:([0-9]+)_([a-zA-Z0-9_%]+)?$ index.php?page=$1&type=$2 [L]
([0-9]+)是匹配page,([a-zA-Z0-9_%]+)是匹配中文编码字符,url就是$page_$type。
就是这么个意思: