这里我写了Nginx规则来重写URL,不知道我在哪里出错。
它应该工作::每当我点击 URL:http://host.com/web/sitemap_index.xml 时,Nginx应该使用 URL:http://host.com/web/index.php?sitemap=1 对其进行重写>。
在下面添加我的Nginx配置:
server {
server_name 0.0.0.0;
root /var/www/html;
listen 80;
index index.html index.htm index.php;
location / {
rewrite /sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite /([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
location ~* \.(css|js|xml|png|jpg|jpeg|gif|ico|ttf|mp4)$ {
expires 365d;
}
}
谢谢