首页 zblog内容详情

Nginx在宝塔目录站使用zblogPHP程序伪静态规则!

2026-01-08 5 897698882
Nginx在宝塔目录站使用zblogPHP程序伪静态规则!

站点名称:Nginx在宝塔目录站使用zblogPHP程序伪静态规则!

所属分类:zblog

官方网址:

SEO查询: 爱站网 站长工具

进入网站

站点介绍

Nginx中文件夹目录站怎么伪静态?简单!

由于Apache比较耗费资源,最近手里的一些站被人打了,导致各种cpu100%状况出现,除了做一些cdn防御之外,也直接从Apache转到Nginx,从各个方面去减少负载,但由于有一个主站使用zblogPHP,同时其子目录也有一些文件夹也有zblogPHP程序,也都执行了伪静态!

在Apache下相当容易,直接复制粘贴伪静态文件.htaccess到目录中,并修改规则中的代码即可,但Nginx则完全不同,相信很多人并不清楚,特别是使用宝塔面板的!

下面分享下我的用法:

先说下默认的zblogPHP伪静态规则,nginx下的:

if (-f $request_filename/index.html){	rewrite (.*) $1/index.html break;}if (-f $request_filename/index.php){	rewrite (.*) $1/index.php;}if (!-f $request_filename){	rewrite (.*) /index.php;}

如果主站是zblogPHP,直接使用上述规则即可,在规则中也可以选择zblog,保存即可!

而如果使用了主站以及同时有子目录站,应该怎么写伪静态规则呢?以主站+go目录站为例:

#主站的规则,因为有目录站,所以也用location括起来。location / {if (-f $request_filename/index.html){	rewrite (.*) $1/index.html break;}if (-f $request_filename/index.php){	rewrite (.*) $1/index.php;}if (!-f $request_filename){	rewrite (.*) /index.php;}}#下方为go文件夹目录站伪静态规则location /go/ {if (-f $request_filename/index.html){	rewrite (.*) $1/index.html break;}if (-f $request_filename/index.php){	rewrite (.*) $1/index.php;}if (!-f $request_filename){	rewrite (.*) /go/index.php;}}