【发布时间】:2016-11-23 18:03:16
【问题描述】:
我客户的网站使用 Wordpress。永久链接设置为/%postname%.php。看到有.php。所以 URL 看起来像http://www.example.com/article-url.php。
我正在使用 Nginx 和 PHP-FPM。该永久链接设置不起作用,因为我收到了File not found 错误。
这是我的 Nginx 服务器块
server {
listen 80;
root /var/www/html/example.com;
index index.php index.html index.htm;
error_log /var/log/nginx/example.com.error.log;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
}
这是错误日志,上面写着FastCGI sent in stderr: "Primary script unknown" while reading re sponse header from upstream ...
如何解决这个问题?
【问题讨论】: