Support » Fixing WordPress » nginx subdirectory "Invalid post type"

  • Resolved mpcabd


    I have an Ubuntu server running Nginx, php-fpm, and wordpress in a subdirectory. My config looks like this:

    server {
            #My site configuration
    		location /blog {
    		        root /home/user/www;
    		        index index.php index.html index.htm;
    		        error_log       /var/log/blog_error.log;
    		        error_page 404 /blog/404.html;
    		        error_page 500 502 503 504 /blog/50x.html;
    		        location /blog/ {
    		                try_files $uri $uri/ /blog/index.php?$args;
    		        location = /blog/favicon.ico { log_not_found off; access_log off; }
    		        location = /blog/robots.txt { allow all; log_not_found off; access_log off; }
    		        location ~ /blog/\. { deny all; }
    		        location ~* /blog/(?:uploads|files)/.*\.php$ { deny all; }
    		        rewrite /blog/wp-admin$ $scheme://$host$uri/ permanent;
    		        if (!-e $request_filename) {
    		                rewrite ^(.*)$ /blog/index.php?q=$1 last;
    		        location ~ \.php$ {
    		                #try_files $uri =404;
    		                fastcgi_split_path_info ^(/blog)(/.*)$;
    		                fastcgi_index blog/index.php;
    		                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    		                include fastcgi_params;
    		                fastcgi_pass unix:/var/run/php5-fpm.sock;
    		        location ~* ^.+\.(css|js|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
    		                access_log off; log_not_found off; expires max;

    With a fresh WP installation version 3.8, I get Invalid post type when I click on the Posts link in my dashboard.

    View post on

    And when I click on Add New Post I get the new post page but the right sidebar which should contain the Post button and other controls shows empty.

    View post on

    I’m sure it has got to do something with my configuration, because I’m trying with a fresh DB and a fresh WP, also the same WP and DB work perfectly if I switch the nginx configuration to subdomain instead of subdirectory.

    Any ideas?


Viewing 2 replies - 1 through 2 (of 2 total)
  • I was having the same issue and found the solution over at the nginx forums.,229298,230201#msg-230201

    The problem, for me, was caused by the line

    fastcgi_split_path_info ^(/blog)(/.*)$;

    I too have my WordPress install in it’s own subdirectory and I read “Non-root try_files to URL redirect” from and just blindly added the line. I don’t understand regex so I don’t know what it’s supposed to do, but it does’t work.

    I commented that line out and now everything works like a charm.
    I’m also no longer getting

    You are not authorized to view this page.


    Hope this helps.

    Thanks a lot, it’s solved just by commenting out this line, it’s so weird though!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘nginx subdirectory "Invalid post type"’ is closed to new replies.