server {
    listen 80;
    # SSL configuration
    #
    listen 443 ssl http2;
    
    ssl_certificate xxxx.pem;
    ssl_certificate_key xxxx.key;

    root /your/path;
    
    index index.html index.htm index.php;

    server_name your.hostname;

    location / {
        # 头像
        rewrite ^/avatar/(.*)$ https://account.isekai.cn/user_center/index.php?m=user&a=getavatar&username=$1&size=middle permanent;
        
        #短链接
        rewrite ^/s/(.*)$ https://www.isekai.cn/%E7%89%B9%E6%AE%8A:%E7%9F%AD%E9%93%BE%E6%8E%A5/$1 permanent;
        
        #域名不正确的跳转
        if ($http_host !~ 'www\.isekai\.cn') {
            rewrite ^/(.*)$ https://www.isekai.cn$request_uri permanent;
        }

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

        try_files $uri $uri/ =404;
    }
    
    location /images/deleted {
        # Deny access to deleted images folder
        deny all;
    }

    # MediaWiki assets (usually images)
    location ~ ^/resources/(assets|lib|src) {
        try_files $uri 404;
        add_header Cache-Control "public";
        expires 7d;
    }

    # Assets, scripts and styles from skins and extensions
    location ~ ^/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg)$ {
        try_files $uri 404;
        add_header Cache-Control "public";
        expires 7d;
    }

    # Favicon
    location = /favicon.ico {
        add_header Cache-Control "public";
        expires 7d;
    }

    location = /status {
        access_log off;
        default_type text/html;
        return 200 'Online';
    }

    location ~ \.php(/.*)$ {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        try_files $fastcgi_script_name =404;

        set $path_info $fastcgi_path_info;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_index index.php;
        include fastcgi.conf;

        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }    

    location ~ \.php$ {
        try_files $fastcgi_script_name =404;
    
        set $path_info $fastcgi_path_info;
        fastcgi_param PATH_INFO $path_info;
    
        fastcgi_index index.php;
        include fastcgi.conf;
    
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

欢迎留言