【问题标题】:wordpress - 404 page not found after updating permalinks w Nginxwordpress - 更新永久链接 w Nginx 后找不到 404 页面
【发布时间】:2016-12-06 18:47:45
【问题描述】:

我更改了我的永久链接结构以使用帖子名 我重新启动 Nginx 以清除缓存,但即使我可以显示我的主页,当我点击任何 oage 链接时,我都会得到一个 404 页面未找到...

使用 Nginx ,我不必更新 .htaccess 文件,但我应该更新我的网站 Nginx conf 文件...

这是与 .php 一起使用的位置部分

      location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass 127.0.0.1:9000;
            # fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params; }

感谢反馈

【问题讨论】:

    标签: wordpress nginx permalinks


    【解决方案1】:

    这不是一个完整的文件部分!服务器 { } 丢失。

    使用这个,但在服务器 {} 之间使用这个,应该可以工作

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass 127.0.0.1:9000;
            # fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params; 
    }
    if (!-e $request_filename) {
        rewrite ^.*$ /index.php last;
     }
    

    【讨论】:

      【解决方案2】:

      将 /location 更新为

       location / {
              # include the "?$args" part so non-default permalinks doesn't break when using query string
              try_files $uri $uri/ /index.php?$args;
        }
      

      现在工作正常...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-11
        • 2016-07-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-06
        • 2015-02-20
        相关资源
        最近更新 更多