子目录中 TYPO3 网站的 Nginx 配置

Nginx configuration for TYPO3 website in subdirectory

我需要 运行 Nginx 上的一个 TYPO3 网站,位于域的子目录中:example.com/subdir

该网站 运行 正常页面正常,但 tx_news-records 页面不正常。一旦调用新闻详细信息页面 (example.com/subdir/detailpages/slug-of-news-record.html),我就会收到以下错误:

#1537633463 OutOfRangeException

Hash not resolvable

这是我的 Nginx 配置:

location ^~/subdir {
    alias /var/www/html/subdirectory;
    disable_symlinks off;
    index index.php index.html index.htm;

    try_files $uri $uri/ @subdir;

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~* ^/subdir/fileadmin/(.*/)?_recycler_/ {
        deny all;
    }

    location ~* ^/subdir/typo3conf/ext/[^/]+/Resources/Private/ {
        deny all;
    }
    
    location ~* ^/subdir/(fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) {
    }
}

location @subdir {
    rewrite /subdir/(.*)$ /subdir/index.php?/$is_args$args last;
}


location ~* ^/subdir/(.*$) {
    return 301 /subdir/;
}

我的 Nginx 配置中缺少什么?一般情况下是否有需要我批准的内容?

经过反复试验,我自己找到了解决方案。以下配置对我有用:

location ^~/subdir {
    alias /var/www/html/subdirectory;
    disable_symlinks off;
    index index.php index.html index.htm;

    try_files $uri $uri/ @subdir;

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~* ^/subdir/fileadmin/(.*/)?_recycler_/ {
        deny all;
    }

    location ~* ^/subdir/typo3conf/ext/[^/]+/Resources/Private/ {
        deny all;
    }
    
    location ~* ^/subdir/(fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) {
    }
}

location @subdir {
    rewrite /subdir/(.*)$ /subdir/index.php?$args last;
}


location ~* ^/subdir/(.*$) {
    return 301 /subdir/;
}

一如既往,这只是一个小小的改变。

location @subdir {
    rewrite /subdir/(.*)$ /subdir/index.php?/$is_args$args last;
}

改为

location @subdir {
    rewrite /subdir/(.*)$ /subdir/index.php?$args last;
}