typecho伪静态规则需要在修改虚拟主机文件

虚拟主机配置文件为:

/usr/local/nginx/conf/vhost/域名.conf

比如我的是/usr/local/nginx/conf/vhost/jocket.top.conf

1.打开伪静态文件:

伪静态规则文件代码需要放在以下文件中:

/usr/local/nginx/conf/xxx.conf(xxx表示你是哪一种的模板)

比如我的是/usr/local/nginx/conf/typecho.conf

2.添加伪静态代码:

将下列代码添加到伪静态文件中(也就是typecho.conf):

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;
}

删除(在typecho.conf文件中):

if (!-e $request_filename) {
  rewrite ^(.*)$ /typecho/index.php$1 last;
  }

3.修改虚拟主机配置文件

打开虚拟主机配置文件:

/usr/local/nginx/conf/vhost/www.xxx.conf

我的是:/usr/local/nginx/conf/vhost/jocket.top.conf
3.1.添加伪静态文件
在配置文件的下面一行

root /home/wwwroot/jocket.top;

在上面一行下添加:

include typecho.conf;

3.2替换文件
include enable-php.conf;
替换为include enable-php-pathinfo.conf;

加完保存,执行重启lnmp命令(以下3种重启方式选一种即可):
(1) /etc/init.d/nginx restart

(2) lnmp restart

(3) lnmp nginx restart

重启生效,如果报错可能是添加有误或伪静态规则有误。

Last modification:November 25th, 2018 at 04:44 pm
If you think my article is useful to you, please feel free to appreciate