Internet Resource

LNMP or Nginx Can’t Display the URL right in WordPress

If you using Nginx and wWordPress, and found that some of your pages can’t open or got 404 error or no right to manage the page, usually there are some problems with your site’s url.

Please go:

/usr/local/nginx/conf/vhost

Edit your site’s conf.

For example:

I opened my site’s conf

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.dobeweb.com dobeweb.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /h/www.dobeweb.com;

        include wordpress.conf;
        #error_page   404   /404.html;
        location ~ [^/]\.php(/|$)
        {
            # comment try_files $uri =404; to enable pathinfo
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            #include pathinfo.conf;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        access_log off;
    }

Add the following code at the end of the config.

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

Save.

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.dobeweb.com dobeweb.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /h/www.dobeweb.com;

        include wordpress.conf;
        #error_page   404   /404.html;
        location ~ [^/]\.php(/|$)
        {
            # comment try_files $uri =404; to enable pathinfo
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            #include pathinfo.conf;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        access_log off;
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    }