简体   繁体   English

Nginx + 漂亮的永久链接问题

[英]Nginx + Pretty Permalink issue

I am having an issue with WP pretty permalink and my nginx conf.我遇到了 WP 漂亮的永久链接和我的 nginx conf 的问题。

  • Homepage works good主页效果很好
  • Post = 404帖子 = 404
  • WP-Admin = 404 WP-管理员 = 404

Can you help me to resolve it?你能帮我解决吗?

Relevant nginx configuration (excludes ssl, gzip, headers, etc.):相关nginx配置(不包括ssl、gzip、headers等):

server {

  server_name sampledomain.com;
  listen 443 ssl http2;

  root /var/www/sampledomain/;
  index index.php;

  ...

  location ~ \.php$ {

    try_files $uri $uri/ /index.php?$args;
    include fastcgi_params;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

Based on your config here , I think you need to add another location block at or before line 39.根据您在此处的配置,我认为您需要在第 39 行或之前添加另一个location块。

For nginx, a web server aimed at high concurrency, high performance and low memory usage, add the following location block within the server block:对于nginx,一个web服务器,针对高并发、高性能和低memory使用率,在服务器块内添加如下位置块:

location / {
  try_files $uri $uri/ /index.php?$args;
}

via WordPress Docs通过WordPress 文档

Example:例子:

server {

  server_name sampledomain.com;
  listen 443 ssl http2;

  root /var/www/sampledomain/;
  index index.php;

  ...

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {

    try_files $uri $uri/ /index.php?$args;
    include fastcgi_params;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM