简体   繁体   中英

Cannot access files inside web folder Symfony (route not found)

I have create a folder named img which contains some images. However, when I try to access it in the url, such as:

http://mydomain.dev/app_dev.php/img/1.png

it doesn't work

Symfony returns me an error saying: No route found for "GET /img/1.png"

However, if I do the following:

http://mydomain.dev/img/1.png

it works !

I am using Apache and running it on Mac OSX Mavericks.

How can I access it in app_dev.php even if it is not a route but a file ?

如果你在web / img / 1.png中插入你的图像并且想要在twig文件中指向它,请尝试:

<img src="{{ asset('img/1.png') }}" />

app_dev.php maps your request to router, which forward request to specific controller. Don't expect valid route to static files. Static files can be added with full path to file(ofc. your static files should be in your web direcory), or by Twig , which can render current path to file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM