Search code examples
symfonyfosrestbundle

How to directly access an image from web directory using FOSREST


As a service, i want to access an image inside of "web/uploads". When i'm trying to do that, it's returning:

No route found for "GET /web/uploads/"

But i just want to access an image inside this directory. I'm uploading images and i need to load them externally. Any light to do this? Thanks.


Solution

  • /web/ directory is you (public) document root, so it's the place where your domain points.

    Assuming e.g. you have virtual host example.lc which points to /path/to/project/web/, then instead of requesting:

    http://example.lc/web/uploads

    You should try with:

    http://example.lc/uploads

    When you're trying to access:

    http://example.lc/web/uploads

    Webserver really looks for /path/to/project/web/web/uploads, and since this path doesn't exist, it rewrites the URL to app.php which is Symfony application entry point.