TonnyORG's avatar

404: Nginx + Lumen + Symlink inside a WP folder p2

This is related to: https://laracasts.com/discuss/channels/lumen/404-nginx-lumen-symlink-inside-a-wp-folder

I made the root path of Lumen works inside a wordpress folder (url.com/), the thing is that it only recognize the root url.com/lumen, but not the other routes like url.com/lumen/action/.

Any idea about this?

Thank you!

0 likes
4 replies
TheNodi's avatar

@TonnyORG

What's the error? (Both display and error.log)

I think you should check the mod rewrite rules in the nginx configuration.

1 like
TonnyORG's avatar

@TheNodi thanks again!

The error is WP 404 error, as you know the main domain runs over WP (so the main server{} block has WP rules). Lumen is configured as public sub-folder (internally works as a symlink).

When I type site.com/lumen/ it works and show up the Lumen content, but if I visit site.com/lumen/sample/ it doesn't and seems like it's handled by WP instead of Lumen because it returns my WP 404 Page.

In the Nginx server block I've this (as you can see I've nothing specific for the Lumen folder):

server {
    listen 80;

        server_name site.com;
        root /path/to/public_html/site.com;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

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

    location ~* ^.+\.(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;
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    }
}
TheNodi's avatar
TheNodi
Best Answer
Level 11

@TonnyORG

I guess it's because all url that doesn't exists as a file are redirected to the wordpress index.php. I'm really bad at nginx configurations (loving forge for that reason), but here's what it should do in order of priority:

  1. If the file exists, serve it
  2. If the url is /lumen/* redirect to lumen's index.php
  3. Else redirect to wordpress index.php

I would try this, but I'm really not sure if it works:

    index index.php;

    location /lumen {
        try_files $uri $uri/ /path/to/lumen/public/index.php?$args;
    }

    location / {
        try_files $uri $uri/ /index.php?$args;
    }
1 like
TonnyORG's avatar

Again you made it works @TheNodi, now the routes and grouped routes work well.

Thank you so much!

Please or to participate in this conversation.