一、如何设置给wordress设置伪静态?
在workpress后台中设置-固态链接-自定义结构,输入/%post_id%.html,你再去看自己文章的链接,后面会多了html的后缀,就算是设计成功了
二、设置了伪静态后,出现了404not found nginx
可能每种情况的处理方式是不同的,我这情况就是原先wordpress的配置不够完整
在你原先的服务器里找到wordpress.conf ,这个文件我的路径是usr/local/nginx/conf 里
然后把以下内容覆盖原来里面的内容,有些内容需要自己稍作修改:
server
{
listen xxxx; //端口
server_name xxxxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/xxxx/wordpress;
include none.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location / {
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;
}
} 覆盖之后,重启一次nginx,然后再去访问你带有html后缀的文章就可以访问了
本文介绍了如何在WordPress中设置伪静态,并针对设置后可能出现的404 Not Found错误,特别是Nginx服务器环境下,提供了解决方案。通过修改wordpress.conf配置文件来修复问题。
4287

被折叠的 条评论
为什么被折叠?



