2016-10-22 161 views
1

有以下NGINX配置:WordPress的永久鏈接在Nginx的404錯誤

server { 
     listen 80; 
     listen [::]:80; 

     server_name <name>; 
     client_max_body_size 32m; 
     root /home/ulnda/www/wordpress; 
     index index.html index.php; 

     location/{ 
       try_files $uri $uri/ =404; 
     } 
     location ~ \.php$ { 
       include snippets/fastcgi-php.conf; 
       include fastcgi_params; 
       fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
       fastcgi_param SCRIPT_FILENAME /home/ulnda/www/wordpress$fastcgi_script_name; 
       fastcgi_param PHP_VALUE post_max_size=20M; 
       fastcgi_param PHP_VALUE upload_max_filesize=20M; 
     } 
} 

網站工作正常域例如http://somedomain.com。但是,當我嘗試打開一些帖子與永久http://somedomain.com/post-about-sea我得到404錯誤。我該如何解決它?謝謝!

回答

5

這一個應該工作。 Nginx不應該在你的配置中返回404。

server { 
     listen 80; 
     listen [::]:80; 

     server_name <name>; 
     client_max_body_size 32m; 
     root /home/ulnda/www/wordpress; 
     index index.html index.php; 

     location/{ 
       try_files $uri $uri/ /index.php?$args; 
     } 
     location ~ \.php$ {     
       include snippets/fastcgi-php.conf; 
       include fastcgi_params; 
       fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
       fastcgi_param SCRIPT_FILENAME /home/ulnda/www/wordpress$fastcgi_script_name; 
       fastcgi_param PHP_VALUE post_max_size=20M; 
       fastcgi_param PHP_VALUE upload_max_filesize=20M; 
     } 
} 
+0

它的工作原理。謝謝! – malcoauri