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. }  
posted @   Oops!#  阅读(2067)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
点击右上角即可分享
微信分享提示