Wordpress category links are not working and sometimes PHP gives a blank page on an Nginx server

February 19, 2015 1.7k views

I just configured a new server to move my website. After I migrated, everything works fine except for category links. If we visit a category, it will give a 404 error. Page permalinks are working fine! What might be the problem? One website gives this problem immediately, the other after sometime. Sometimes even the posts go missing.

Sometimes I even get a problem of having blank pages for php files.

The nginx conf :

    server {
            listen   80;

            root /var/www/androidgadgematic;
            index index.php index.html index.htm;


            location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;

            location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
                expires 10d;

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

            location = /50x.html {
                  root /usr/share/nginx/www;

            location ~ /\. {
                    deny all;
                    access_log off;
                    log_not_found off;

            location ~ /nginx.conf {
                    deny all;
                    log_not_found off;
                    access_log off;

            location ~ ^/feed/(.+)\.html$ {
                    if ($args != '') {
                    rewrite ^(.*) $1? permanent;

            # pass the PHP scripts to FastCGI server listening on
            location ~ \.php$ {
                    try_files $uri =404;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    include fastcgi.conf;

            include /var/www/androidgadgematic/nginx.conf;
            location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
            location ~ "^/ngx_pagespeed_static/" { }
            location ~ "^/ngx_pagespeed_beacon$" { }
            location /ngx_pagespeed_statistics { allow; deny all; }
            location /ngx_pagespeed_global_statistics { allow; deny all; }
            location /ngx_pagespeed_message { allow; deny all; }
            location /pagespeed_console { allow; deny all; }

            location ^~ /wp-login.php {
                    auth_basic            "Restricted Area: WordPress";
                    auth_basic_user_file  /var/www/.htpasswd;
                    try_files $uri =404;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    include fastcgi.conf;


PS : Even the wp-admin gives 404


    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;

    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  REQUEST_URI        $request_uri;
    fastcgi_param  DOCUMENT_URI       $document_uri;
    fastcgi_param  DOCUMENT_ROOT      $document_root;
    fastcgi_param  SERVER_PROTOCOL    $server_protocol;
    fastcgi_param  HTTPS              $https if_not_empty;

    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

    fastcgi_param  REMOTE_ADDR        $remote_addr;
    fastcgi_param  REMOTE_PORT        $remote_port;
    fastcgi_param  SERVER_ADDR        $server_addr;
    fastcgi_param  SERVER_PORT        $server_port;
    fastcgi_param  SERVER_NAME        $server_name;

    # PHP only, required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS    200;

PS : I downloaded and compiled Nginx from source to install page speed. Might this be the problem?

  • Do you have plugins like W3 Total Cache installed? Try disabling it and see if it works.

  • @jesin Yes I disabled W3TC and tried. But didn't work.

  • @THpubs After disabling W3TC comment out the line include /var/www/androidgadgematic/nginx.conf; reload Nginx and check if it works.

    Also edit wp-config.php, set the value of WP_DEBUG to true and check if any PHP errors are displayed on those blank pages.

    Can you post your site's URL if possible.

  • @jesin I commented out the nginx.conf line and still didn't work. I will check for WP errors thanks!

  • i face this problem too all post normal but category show blank page :( any suggestion?

1 Answer

i face this problem too, for other post is working perfect but category only show blank pages.. any suggest?

Have another answer? Share your knowledge.