TypechoJoeTheme

Dcr163的博客

统计

PHPCMS nginx下伪静态

2019-07-19
/
0 评论
/
964 阅读
/
正在检测是否收录...
07/19

首先是必须要在PHPCMS的栏目后台把HTML规则设置成伪静态的规则:

上面的url规则可以在:后台管理->扩展->URL规则管理 里自定义添加;
配置好栏目规则后,需要更新url链接,废话不多说,下面是nginx的重写配置,在后面详细介绍使用方法

        location / {
            rewrite ^/show-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
            rewrite ^/content-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
            rewrite ^/list-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&page=$2 last;
            rewrite ^/tag-([^\.]*)-([0-9]+)-([0-9]+).html /index.php?m=content&c=tag&catid=$2&tag=$1&page=$3 last;
            rewrite ^/tag/list-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&page=$2 last;
            rewrite ^/tag/(.*)$ /index.php?m=content&c=tag&a=lists&tag=$1&%1 last;
            rewrite ^/comment-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=comment&c=index&a=init&commentid=content_$1-$2-$3 last;
            rewrite ^/([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
        }

拿一条重写规则说明,后面的重写规则都是同理:

rewrite ^/show-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;

上面的意思是当前URL为 www.dcr163.cn/show-12-21-1.html 的时候,nginx把链接重写到  

/index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;

其中重写后的几个参数 $1,$2,$3分别对应前面的()括号里的变量,一个() 对应一个后面的变量,经过上面的重写规则,nginx就实现了PHPCMS的重写。
修改完nginx记得一定要重加载nginx配置文件重启nginx服务

朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

https://dcr163.cn/401.html(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. William Tardent
    2024-02-27
  2. Maryann Hamer
    2024-02-27
  3. Sanora Pantano
    2024-02-24
  4. aa
    2024-02-21
  5. Kassie Baum
    2024-01-28

标签云