wordpress nginx 伪静态问题

2015-03-08 12:22:35 +08:00
 holinhot

配置了以下规则
rewrite ^./files/(.)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.) $1 last;
rewrite ^.+?(/.
.php)$ $1 last;
rewrite ^ /index.php last;
}

网站没什么不正常的地方
但是wordpress已经内置了一个404页面在apache下运行正常
但是nginx下404页面显示的是nginx的404页面而不是wordpress内置的404页面这是怎么会事

3118 次点击
所在节点    NGINX
7 条回复
kn007
2015-03-08 12:44:07 +08:00
添加 try_files $uri =404;
示例:
location ~ .*\.php?$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
holinhot
2015-03-08 12:55:55 +08:00
@kn007 \.php?要加到这个区域?
holinhot
2015-03-08 12:56:29 +08:00
@kn007 location / {
try_files $uri $uri/ /index.php?$args;
try_files $uri =404;
} 看起来不行
holinhot
2015-03-08 13:04:07 +08:00
已搞定 要加到php区域
kn007
2015-03-08 13:04:48 +08:00
添加到php区域,还有不能同事tryfiles,要合并
如try_files $uri $uri/ /index.php?$args =404;
ab
2015-03-08 16:17:14 +08:00
location / {
try_files $uri $uri/ /index.php?$args;
}

这段搞定一切,不用加到php段
ryd994
2015-03-09 01:52:14 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/175310

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX