我有这个nginx配置,尝试将 mysite.com/user/1234 重写为 mysite.com/user.php?id=1234 。但是,我收到404错误。我的代码有什么问题?
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name [[MYSITE]];
location / {
rewrite ^/user/(.*)$ /user.php?id=$1 last;
try_files $uri $uri/ @extensionless;
}
location @extensionless {
rewrite ^(.*)$ $1.php last;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_read_timeout 3000;
}
[...]