Typecho程序安装在子目录Nginx伪静态规则如何设置
设置typecho在如xxx.com/typecho目录下访问,同时后台要开启rewrite,这样设置xxx.com可以运行别的网站程序,通过xxx.com/typecho访问typecho
nginx.conf配置文件server节点下的内容:主要把注释部分换成自己的
假设typecho安装在了 /site/typecho,进行如下配置
# typecho目录所在的目录名
root /site;
index index.php index.html index.htm;
# typecho目录名
location /typecho{
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php) {
rewrite (.*) $1/index.php last;
}
if (!-f $request_filename) {
# 替换
rewrite (.*) /typecho/index.php last;
}
}
location ~ .*\.php(\/.*)*$ {
include fastcgi.conf;
include fastcgi_params;
fastcgi_pass unix:/run/php/php-fpm.sock;
# include fastcgi.conf;
# fastcgi_pass 127.0.0.1:9000;
}