Search code examples
localizationlocalephp-7symfony-4.3

Symfony 4.3.5 - locale loading nonexistent public


In Symfony 4.3.5 when using locale in url (e.q. http://127.0.0.1:8000/en/example), framework starts loading nonexisting public route to resources;
/en/images/like-icon-58x25.png instead images/like-icon-58x25.png.

I got 404 on each of these resources when server tries to access public route with locale prefixed in route, only plain HTML loads:
[Wed Jan 29 19:17:30 2020] 127.0.0.1:50790 [404]: /en/css/bootstrap.css
[Wed Jan 29 19:17:30 2020] 127.0.0.1:50794 [404]: /en/css/style.css
[Wed Jan 29 19:17:30 2020] 127.0.0.1:50792 [404]: /en/css/fonts.css
[Wed Jan 29 19:17:30 2020] 127.0.0.1:50796 [404]: /en/images/logo-proizd-team-2019-web2.png
[Wed Jan 29 19:17:30 2020] 127.0.0.1:50798 [404]: /en/images/project-1-195x164.jpg
[Wed Jan 29 19:17:30 2020] 127.0.0.1:50800 [404]: /en/js/core.min.js
[Wed Jan 29 19:17:30 2020] 127.0.0.1:50802 [404]: /en/js/script.js

How to solve this problem. Could not find similar problems and solutions.


Solution

  • I've found solution.
    Since I'm using Twig, assets must be put into asset() function.

    e.g. src="{{ asset('images/like-icon-58x25.png') }}"