lnmp wordpress固定链接设置后页面404报错
问题:wordpress-设置-“固定链接”配置页面,自定义链接的结构 “http://www.abc.com/%postname%/,保存更改后,文章和分类页面访问,都提示404报错
解决方案:访问网站对应的域名配置文件abc.com.conf
默认的配置文件如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 | server { listen 80; server_name www.osetc.com; index index.html index.htm index.php; root /wwwroot/abc.com; //注意此处,将下面的几行if代码copy到这里 location ~ .*.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } |
需要添加的代码:
1 2 3 4 5 6 7 8 9 10 11 | if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; }if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; }if (!-f $request_filename){ rewrite (.*) /index.php; } |
配置完成,重启lnmp
[cc lang="php"]
/root/lnmp restart
[/cc]