Learn about Centmin Mod LEMP Stack today
Become a Member

Wordpress 404 not found permalink error on wordpress

Discussion in 'Blogs & CMS usage' started by Daniel, Sep 3, 2014.

  1. Daniel

    Daniel New Member

    5
    1
    1
    Sep 3, 2014
    Ratings:
    +1
    Local Time:
    4:16 AM
    1.7.4
    10
    Hello @eva2000 ,
    I continue my question here.
    I use centmin yesterday, and I already followed all step here :
    Getting Started with Centmin Mod
    And then, when I get permalink error for postname,
    I did steps here : Nginx Wordpress Configuration Examples for rewrite rules & FastCGI Caching
    but still get same 404 error.
    FYI, first I use cloudflare as my dns. Then I try to pause it, but same error result.
    Which step I failed?
    Please advise :)
    Thank you

     
  2. eva2000

    eva2000 Administrator Staff Member

    53,865
    12,160
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,712
    Local Time:
    6:16 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    are you using permalinks with .html extension ?

    that is because Centmin Mod default static files include file at /usr/local/nginx/conf/staticfiles.conf handles .html files via Nginx

    but by using wordpress with .html extensions you tell Nginx not to serve .html files and serve via PHP-FPM (not ideal as it reduces performance if you use permalinks with .html extensions and thus use PHP-FPM to server .html files)

    If you must use .html extension permalinks, you need to comment out the .html location context from /usr/local/nginx/conf/staticfiles.conf and restart Nginx server as illustrated below with hash # in front
    Code:
        location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
            gzip_static off;
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        location ~* \.(js)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        location ~* \.(css)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        #location ~* \.(html|htm|txt)$ {
            #add_header Pragma public;
            #add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            #access_log off;
            #expires 1d;
           # break;
           # }
    
        location ~* \.(eot|svg|ttf|woff)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
     
  3. eva2000

    eva2000 Administrator Staff Member

    53,865
    12,160
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,712
    Local Time:
    6:16 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  4. Daniel

    Daniel New Member

    5
    1
    1
    Sep 3, 2014
    Ratings:
    +1
    Local Time:
    4:16 AM
    1.7.4
    10
    No, I'm not use html extension.
    Just use postname.
    Already followed steps here to Nginx Wordpress Configuration Examples for rewrite rules & FastCGI Caching
    Also followed step here > Nginx Wordpress + WP-FFPC Plugin Setup + ngx_pagespeed
    if ( $memcached_request = 0) {
    rewrite ^ /index.php?q=$request_uri last;
    }
    so, the location / is :

    location / {
    include /usr/local/nginx/conf/wpsecure.conf;
    include /usr/local/nginx/conf/wpcache.conf;
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;

    # Enables directory listings when index file not found
    #autoindex on;

    # Shows file listing times as local time
    #autoindex_localtime on;

    # Enable for vBulletin usage WITHOUT vbSEO installed
    #try_files $uri $uri/ /index.php;
    #index index.php
    #try_files $uri $uri/ /index.php?q=$request_uri;
    try_files $uri $uri/ @memcached;
    }
    Am I did wrong? :-/
     
  5. eva2000

    eva2000 Administrator Staff Member

    53,865
    12,160
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,712
    Local Time:
    6:16 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  6. Daniel

    Daniel New Member

    5
    1
    1
    Sep 3, 2014
    Ratings:
    +1
    Local Time:
    4:16 AM
    1.7.4
    10
  7. eva2000

    eva2000 Administrator Staff Member

    53,865
    12,160
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,712
    Local Time:
    6:16 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    i wouldn't deploy Cloudflare until after you have a working Wordpress configuration ;)
     
  8. Sébastien d'Olbecke

    Sébastien d'Olbecke New Member

    2
    2
    3
    Dec 13, 2014
    Ratings:
    +2
    Local Time:
    4:16 AM
    1.7.7
    5.5.39
    Hi there, here's the solution that worked for me. Go into your conf.d/mydomain.com.conf and add what's between "You should add from here and #to here.

    Code:
    server {
      server_name mydomain.com www.mydomain.com;
      index index.php index.html index.htm;
    
    #You should add from here
    # enforce NO www
        if ($host ~* ^www\.(.*))
        {
        set $host_without_www $1;
        rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
        }
    
    # unless the request is for a valid file, send to bootstrap
        if (!-e $request_filename)
        {
        rewrite ^(.+)$ /index.php?q=$1 last;
        }
    #to here
    #there are some more lines below then the last bracket
    }
    
    ALSO, comment the following line to not use it in your
    Code:
     location /mywordpresslocation {
    #    try_files $uri $uri/ /public/index.php?$args;
    } 
    Hope this helps