步骤

  • 后台配置:到后台配置参数中开启伪静态。
  • 配置Nginx虚拟主机:在Nginx虚拟主机 location 配置中添加规则,规则如下:
location / {
    if (!-e $request_filename){
        rewrite ^/index.php(.*)$ /index.php?p=$1 last;
        rewrite ^(.*)$ /index.php?s=$1 last;
    }
}

注意:Nginx中如果站点部署在二级目录,请对应修改重写规则。例如,二级目录为 test,则规则应为:

rewrite ^/test/(.*)$ /test/index.php?p=$1 last;