douewei1665 2016-11-22 19:10
浏览 87

Nginx的WordPress HTTPS(SSL)永久链接配置

I've installed Nginx, PHP-FPM,SSL certificate (Let's Encrypt), and WordPress 4.6.1 on my server and working well. But, when I change the permalink settings to anything other than default,I get 404 errors on every post,article and page. In my nginx config file I have the following code under my location / block :

try_files $uri $uri/ /index.php?$args;

Here is my nginx.conf:

server {
    listen      xxx.xxx.xxx.xxx:80;
    server_name raharja.com www.raharja.com;
    root        /home/admin/web/raharja.com/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/raharja.com.log combined;
    access_log  /var/log/nginx/domains/raharja.com.bytes bytes;
    error_log   /var/log/nginx/domains/raharja.com.error.log error;

    location / {

        # WordPress permalinks configuration
        try_files $uri $uri/ /index.php?$args;

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    127.0.0.1:9001;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   /home/admin/web/raharja.com/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;

    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/admin/conf/web/nginx.raharja.com.conf*;
try_files $uri $uri/ /index.php?$args;
}

Does anyone have a solution?

  • 写回答

1条回答 默认 最新

  • douren5490 2016-11-22 20:49
    关注

    I suggesting you try this:

     if (!-e $request_filename)
        {
           rewrite ^(.+)$ /index.php?q=$1 last;
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题