wordpress配置固定鏈接nginx訪問404問題解決方法


WordPress支持使用固定鏈接,但是在ngnix環境下,訪問頁面后出現404,

其實官方是有文檔說明的,需要單獨寫配置,

我這邊配置的示例代碼如下:

 

[plain]  view plain  copy
 
  1. server {  
  2.     listen       80;  
  3.     server_name  www.chaichunyan.com;  
  4.   
  5.     access_log  /var/log/nginx/access.log  main;  
  6.   
  7. location / {  
  8.         root /www/data/xxx;  
  9.         index  index.php index.html index.htm;  
  10.   
  11.         if (-f $request_filename/index.html){  
  12.                rewrite (.*) $1/index.html break;  
  13.         }  
  14.         if (-f $request_filename/index.php){  
  15.                rewrite (.*) $1/index.php;  
  16.          }  
  17.         if (!-f $request_filename){  
  18.                rewrite (.*) /index.php;  
  19.          }  
  20. }  
  21. rewrite /wp-admin$ $scheme://$host$uri/ permanent;  
  22.   
  23.     location  ~ \.php$ {  
  24.         root /www/data/xxx;  
  25.         fastcgi_pass   127.0.0.1:9000;  
  26.         fastcgi_index  index.php;  
  27.         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;  
  28.         include        fastcgi_params;  
  29.     }  
  30. }  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM