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;
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?