I'm using Magento 2.4.4, I've set up the existing project, but all page goes to 404 except the homepage. I'm using Nginx for the first time so still figuring out how to configure it.


server {
    listen 80;
    server_name ruralking.local www.ruralking.local;
    root /var/www/ruralking.local/pub;

    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ =404;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_buffers 16 256k;
        fastcgi_buffer_size 256k;

    location ~ /\.ht {
        deny all;

1 Answer 1


Your nginx use the pub folder as document root folder. See the magento docs for more information. In this case, you have to set the following node to the array in you environment file (app/etc/env.php):

'directories' => [
  'document_root_is_pub' => true,

Did you set this node?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.