Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel nginx.conf with official Heroku php buildpack?

I have the following in `nginx.conf in my project root

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

But only in the / path works, all others are coming up with a 404 error.

How can I make Laravel work on heroku with nginx?

like image 631
cactusphone Avatar asked Dec 11 '22 00:12

cactusphone


1 Answers

This ended up working for me: Procfile:

web: vendor/bin/heroku-php-nginx -C nginx.conf public/

nginx.conf

location / {
    # try to serve file directly, fallback to rewrite
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    # rewrite all to app.php
    rewrite ^(.*)$ /index.php$1 last;
}
like image 85
cactusphone Avatar answered Jan 09 '23 09:01

cactusphone