How to fix nginx error 404

Dunk92

Member
Registered
Joined
Apr 15, 2018
Messages
43
Points
6
I use Nginx on Wordpress site.
Every page disappeared, except homepage, and we got ''404 not found.''
I dont know how I triggered this problem.
How can I fix this problem ?
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
I use Nginx on Wordpress site.
Every page disappeared, except homepage, and we got ''404 not found.''
I dont know how I triggered this problem.
How can I fix this problem ?
Hello,
you have to check your nginx configuration, 404 not found on wordpress mean the permalinks are not rewritten properly.

Your vhost should look like :
NGINX:
server {
        ## Your website name goes here.
        server_name domain.tld;
        ## Your only path reference.
        root /var/www/wordpress;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
                fastcgi_buffers 16 16k;
                fastcgi_buffer_size 32k;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}
more configuration examples are available in the wordpress codex
 

Dr. McKay

Well-known member
Registered
Joined
Nov 26, 2016
Messages
565
Points
28
Dr. McKay
Nice codes but I afraid of using Nginx because I have to use codes to control configurations or setups. Is there a way that using nginx without using more codes or only using clicks only?
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
VirtuBox
Excepted with some control panels like Plesk, VestaCP or CentosWebPanel (and even with them you may have to edit nginx configuration manually) Nginx is exactly like Apache, when you want to add a domain, you have to create a vhost and to set the proper settings for your domain.
But there are command line tools like EasyEngine or Centminmod to create nginx vhost automatically and to reduce as much as possible manual configuration. Otherwise, you can also find easily some configuration generator for nginx like https://nginxconfig.io/
 

Gmeister4

Well-known member
Registered
Joined
Apr 19, 2016
Messages
178
Points
18
Gmeister4
Is Plesk still requiring manually configure some parts with it to work websites. I am confusing this because I have Plesk and hosting websites on it but problems are solved by my providers, I only submit tickets.

For example, I used Apache, I need setup rewrite rules in .htaccess file but how for Plesk? can I do a same file with Plesk or how?
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
VirtuBox
Plesk use Apache + Nginx to make static content loading faster (because Nginx do the job better than Apache) but also to support .htaccess because php-fpm is managed by Apache. So it provide better performance, without impacting your application compatibility.

But you can also use Nginx to managed php-fpm process, but Nginx will not read .htaccess and it require to set your rewrite rules in the section Apache & Nginx settings > additional directives for Nginx
 
Older Threads
Replies
2
Views
1,858
Replies
20
Views
7,554
Replies
5
Views
2,828
Replies
9
Views
4,893
Newer Threads
Replies
8
Views
4,324
Replies
2
Views
1,910
Replies
0
Views
1,331
Recommended Threads
Replies
12
Views
7,258
Replies
3
Views
1,733
Replies
2
Views
3,302
Similar Threads
Replies
7
Views
1,058
Replies
5
Views
1,129
Replies
5
Views
1,229
Replies
5
Views
1,795

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top