目 录CONTENT

文章目录

Typecho配置Rewrite规则

IKun
2023-01-25 / 0 评论 / 0 点赞 / 2 阅读 / 1647 字

首先在你的Nginx服务器上配置了 yourdomain.conf 文件,注意不是 nginx.conf 文件,文件存储路径一般为

/usr/local/nginx/conf/vhost/yourdomain.conf

yourdomain.conf 配置文件中找到 server 配置段,在其中加入下面一段代码

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

而其他不需要修改,保存重启服务器。

例如我的配置文件为 www.conimi.com.conf ,配置完成如下,

## Version 2022/10/04 - Changelog: https://github.com/linuxserver/docker-baseimage-alpine-nginx/commits/master/root/defaults/nginx/site-confs/default.conf.sample

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;

    server_name _;

    set $root /app/www/public;
    if (!-d /app/www/public) {
        set $root /config/www;
    }
    root $root;
    index index.html index.htm index.php;
    if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php$1 last;
}

    location / {
        # enable for basic auth
        #auth_basic "Restricted";
        #auth_basic_user_file /config/nginx/.htpasswd;

        try_files $uri $uri/ /index.html /index.php$is_args$args =404;
    }

    location ~ ^(.+\.php)(.*)$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
    }

    # deny access to .htaccess/.htpasswd files
    location ~ /\.ht {
        deny all;
    }
}
  1. 后台配置Typecho实现静态化
  2. 第一步完成后,登录博客后台,进入 设置→永久链接
0
博主关闭了所有页面的评论