我正在将一个站点从Apache服务器移动到nginx服务器。很多页面都有一个。permalink末尾的php扩展。尝试查看这些页面会导致找不到nginx 404。然而,这些页面在Apache上运行良好。以下是站点的服务器块配置:
# Vhost Config: example.com
server {
root /var/www/vhosts/sites/www.example.com/web;
index index.php index.html index.htm;
server_name example.com www.example.com;
port_in_redirect off;
location /Denied {
return 403;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* ^(/sitemap).*(\\.xml)$ {
rewrite ^ /index.php;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location = /404.html {
root /usr/share/nginx/html;
}
location ~ ^/.*\\.php$ {
try_files $uri = 404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* \\.(js|css|png|jpg|jpeg|gif|ico|xml)(\\?ver=[0-9.]+)?$ {
expires 1w;
log_not_found off;
}
location ~ /\\. {
deny all;
}
location = /ping.html
{
access_log off;
}
}
我注释掉了“#try\\u files$uri=404;”看看这是否可行,但结果是“找不到文件”消息
因此,主要的问题是试图让WordPress和nginx看到带有的永久链接。php扩展,然后再尝试运行。它看到的php文件不是真实的文件。
这可能吗?