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

  • Posted on February 19, 2015
  • THpubsAsked by THpubs

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?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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