WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] nginx subdirectory "Invalid post type" (3 posts)

  1. mpcabd
    Member
    Posted 7 months ago #

    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;
    		                break;
    		        }
    		        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.

    http://i.stack.imgur.com/oExqD.png

    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.

    http://i.stack.imgur.com/kPEfs.png

    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?

    Thanks.

  2. Duves
    Member
    Posted 7 months ago #

    I was having the same issue and found the solution over at the nginx forums.
    http://forum.nginx.org/read.php?2,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 Nginx.org 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.

    error.

    Hope this helps.

  3. mpcabd
    Member
    Posted 7 months ago #

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

Reply

You must log in to post.

About this Topic