Search code examples
herokusymfony5easyadmin

symfony5 - heroku - urls 404 not found


I am using Symfony 5, and have installed easyAdmin 3.1 bundle.

It works fine in my localhost using:

https://127.0.0.1:8000/admin

However when I deploy to my heroku account I get error when accessing the /admin :

404 : The requested URL was not found on this server.

my heroku app url is:

https://symfony-aristos.herokuapp.com/admin

As a matter of fact this happens with any url other that /. So it's something with the redirects.

https://symfony-aristos.herokuapp.com/login

In heroku logs all I see is:

2020-11-25T07:58:41.279377+00:00 app[web.1]: 10.11.131.158 - - [25/Nov/2020:07:58:41 +0000] "GET /admin HTTP/1.1" 404 196 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36

Is there anything else missing on heroku side to get it working?


Solution

  • I hope this helps other people:

    Symfony 4 and newer applications no longer contain a .htaccess or other configuration to allow rewriting of URLs in such a way that they do not require the index.php script in the path.

    An easy fix this is to require the apache-pack

    $ composer require symfony/apache-pack
    $ git add composer.json composer.lock symfony.lock public/.htaccess
    $ git commit -m "apache-pack"