简体   繁体   中英

Nginx + Pretty Permalink issue

I am having an issue with WP pretty permalink and my nginx conf.

  • Homepage works good
  • Post = 404
  • WP-Admin = 404

Can you help me to resolve it?

Relevant nginx configuration (excludes ssl, gzip, headers, etc.):

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.

For nginx, a web server aimed at high concurrency, high performance and low memory usage, add the following location block within the server block:

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

via WordPress Docs

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;
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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