• I am encountering a weird problem on my NGINX server.

    As explained in the Codex I moved wordpress from my root directory to a subdirectory /blog/.

    It shows the blog index successfully, but if I want to show anything else it serves the root index.php

    Examples:

    https://jascha.io/blog/48-hour-product/
    https://jascha.io/blog/blogger-outreach/

    Even non-existent URLs are served as the root index.php

    https://jascha.io/blog/asdkj23/

    If I remove the root index.php it returns an 404 error.

    Maybe its due to my nginx and fastcgi settings, but I have no clue:

    location ~ \.php$ {
                    try_files $uri =404;
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_cache  microcache;
                    fastcgi_cache_key $scheme$host$request_uri$request_method;
                    fastcgi_cache_valid 200 301 302 30s;
                    fastcgi_cache_use_stale updating error timeout invalid_header http_500;
                    fastcgi_pass_header Set-Cookie;
                    fastcgi_no_cache $no_cache;
                    fastcgi_cache_bypass $no_cache;
                    fastcgi_pass_header Cookie;
                    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    include fastcgi_params;
            }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, jaschaio, & welcome to the WordPress support forum. Can we please see the .htaccess & the index.php files in both your blog & root directories? Please specify which is which, if you would, so there’s no confusion.

    Thanks so much for including a link to your site. It really is very helpful.

    Thread Starter jaschaio

    (@jaschaio)

    Thanks Jackie, I got the answer:

    The try_files statement is sending all none-existent files to index.php in the web root. I needed to add a second location specifically for the blog to the configuration:

    location /blog {
            try_files $uri $uri/ /blog/index.php;
        }

    Now it works fine.

    (Thanks to Steve E. who pointed this out on StackOverflow)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress in sub-directory is serving root index.php on nginx fastcgi’ is closed to new replies.