V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
holinhot
V2EX  ›  NGINX

wordpress nginx 伪静态问题

  •  
  •   holinhot · 2015-03-08 12:22:35 +08:00 · 3101 次点击
    这是一个创建于 3339 天前的主题,其中的信息可能已经有所发展或是发生改变。

    配置了以下规则
    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页面这是怎么会事

    7 条回复    2015-03-09 01:52:14 +08:00
    kn007
        1
    kn007  
       2015-03-08 12:44:07 +08:00   ❤️ 1
    添加 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
        2
    holinhot  
    OP
       2015-03-08 12:55:55 +08:00
    @kn007 \.php?要加到这个区域?
    holinhot
        3
    holinhot  
    OP
       2015-03-08 12:56:29 +08:00
    @kn007 location / {
    try_files $uri $uri/ /index.php?$args;
    try_files $uri =404;
    } 看起来不行
    holinhot
        4
    holinhot  
    OP
       2015-03-08 13:04:07 +08:00
    已搞定 要加到php区域
    kn007
        5
    kn007  
       2015-03-08 13:04:48 +08:00
    添加到php区域,还有不能同事tryfiles,要合并
    如try_files $uri $uri/ /index.php?$args =404;
    ab
        6
    ab  
       2015-03-08 16:17:14 +08:00
    location / {
    try_files $uri $uri/ /index.php?$args;
    }

    这段搞定一切,不用加到php段
    ryd994
        7
    ryd994  
       2015-03-09 01:52:14 +08:00 via Android
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1207 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:19 · PVG 07:19 · LAX 16:19 · JFK 19:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.