mercredi 13 juin 2018

Laravel routing and NGINX Config

I'm trying to set up a new Laravel app using an existing NGINX config... the idea is that it would be accessible at https://ift.tt/2yeyI38. However, I can't seem to get the NGINX configuration working:

location /newapp{
    rewrite ^/newapp/(.*)?$ /newapp/public/index.php?$1 last;
    try_files $uri $uri/ /index.php?$query_string;
} 

This just takes me to the 404 page for every route I try. Here is a sample route:

Route::get('/', function(){
    return "hello, world!";
});

On a whim, I tried changing the default route to use "newapp" in the path, and lo and behold - it worked!

Route::get('/newapp', function(){
    return "hello, world!"; // This works for some reason?
});

I don't understand what is going on here... It seems like the route should not include "newapp" after being rewritten. When I look at the NGINX logs, I see something like this:

rewritten data: "/newapp/public/index.php", args: ""

Which is exactly what I'd expect- why does the route seem to need "newapp", even though it's not part of the arguments passed to index.php?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire