Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Nginx, centmin, wordpress permalink.html = 404 Not Found?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Nginx, centmin, wordpress permalink.html = 404 Not Found?

Mon5t3rMon5t3r Member
edited November 2011 in Help

Hi,

Just my another noobs question, i have a client, he's installing centmin on his VPS, everything look good except the permalink/rewrite rules. he got 404 error when he put /%category%/%postname%.html in permalink. i did try the same config on my test vps with script from server reviews, froxlor, or even ispconfig with no problem. anyone had same issue?

thanks. :D

Comments

  • tdc_admtdc_adm Member
    edited November 2011

    Hello,

    If you client gets 404 error pages of nginx (not 404 pages of wordpress) then it seems that nginx does not pass permalinks to php-fpm. You should review the nginx config file to ensure nginx will pass permalinks to php-fpm. You will need somethings like:

    location / {
            # This is cool because no php is touched for static content
            try_files $uri $uri/ /index.php;
    }

    if your client setups wordpress insie a sub-directory of document root, modify /index.php to /sub-directory/index.php

    An example here: http://wiki.nginx.org/Wordpress

    P/S: after editing config file, don't forget to restart/reload nginx

    Thanked by 1Mon5t3r
  • Add the following code in Nginx config. Don't forget to invoke cofig :P

        location / {
            index index.php;
            if (!-e \$request_filename) {
                rewrite ^(.*)$  /index.php last;
            }
        }
    Thanked by 1Mon5t3r
  • @tdc_adm @iKocka thanks :D but still not solved. :(

    i can access it when i try to put /%category%/%postname% in permalink options. let say :

    blabla.com/category1/post1

    but not for /%category%/%postname%.html -> blabla.com/category1/post1.html

    and this only appear in centmin from BTCentral.

  • It's strange. My wordpress site uses same .html extension like your client. Could you quote the nginx config file (server part).

  • Mon5t3rMon5t3r Member
    edited November 2011

    sure..

    blabla.com.conf

    server {
      server_name blabla.com www.blabla.com;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/blabla.com/log/access.log;
      error_log /home/nginx/domains/blabla.com/log/error.log;
    
      root /home/nginx/domains/blabla.com/public;
    
      location / {
        index index.php;
        try_files $uri $uri/ /index.php;
        include wp_params;
      }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
    }
    

    wp_params

    if (-f $request_filename) {
    break;
    }
    if (-d $request_filename) {
    break;
    }
    rewrite ^(.+)$ /index.php?q=$1 last;
    error_page  404  = //index.php?q=$uri;
    
  • netomxnetomx Moderator, Veteran

    there's the problem, check line 22

  • ah ok, i got it now. it's from staticfiles.conf

    location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
        expires 30d;
        break;
            }
  • Oh, you catched the problem :) I also did remove .html from my staticfiles.conf but I forgot it this time.

    By the way, you should remove this line:

    include wp_params;

    Because

    try_files $uri $uri/ /index.php;

    handles the same logic in a better way.
    References:
    http://wiki.nginx.org/IfIsEvil
    http://wiki.nginx.org/Pitfalls

    Thanked by 1Mon5t3r
  • @tdc_adm yeah.. i put the wp_params -> remove the try_files and vice versa -> put them all together, etc. i'm little bit frustrated you know. :P

Sign In or Register to comment.