<p>I am new to Craft 3 and I have seen similar questions asked many but never answered.</p>

<p>I want to store my images in a directory that is not public, yet I want them to be served correctly by Craft. The reason why I am doing this is that I work with shared disks for EC2 instances in AWS (Not S3) so I need to be able to mount shared volumes to store images for all the Front Ends to serve.</p>

<p>I am experimenting (without mounting a disk, to simplify) and I have a volume with:</p>

<pre><code>name: images
handle: images
Assets in this volume have public URLs: on
Base URL: @web/somestuff
Volume Type: local folder
File System Path: /var/www/mydomain.com/imagesrepo
</code></pre>

<p>Note that the directory /var/www/mydomain.com/imagesrepo has 777 rights, images are uploaded correctly in the CMS, and even "image transform" correctly creates subdirectories and resizes images. I see the images thumbnails but, following the problem explained below, the image shows a broken  when I click on "preview".</p>

<p>Also note that in the directory tree, imagesrepo is outside the website root, at the same level with the "web", "config", etc... directories for Craft. (/var/www/mydomain.com/web is the website root)</p>

<p>I have installed "element api" and I am getting the URL of the image with </p>

<pre><code>$img-&gt;getUrl(),
</code></pre>

<p>and a "resized" version with </p>

<pre><code>$img-&gt;getUrl('largepic').
</code></pre>

<p>The result URLs I am getting are</p>

<pre><code>https://mydomain.com/somestuff/2013-12-22-23.46.18.jpg
https://mydomain.com/somestuff/_largepic/2013-12-22-23.46.18.jpg
</code></pre>

<p>The URLs look correctly built and I would expect that, once called, Craft would fetch the image file with the actual disk location in /var/www/mydomain.com/imagesrepo and read it out to the front end. Instead I get a 404 page with </p>

<pre><code>HTTP 404 – Not Found – yii\web\NotFoundHttpException
</code></pre>

<p>and the whole stack trace, as if Craft was trying to find "somestuff" as a regular template.</p>

<p>Am I doing something wrong or is Craft not able to store assets in a physical location and serve them from a logical one?</p>

<p>P.s. Please do not tell me that there are drivers and plugins for AWS solutions. There are many reasons to store assets in physical locations that differ from the URL</p>

CC BY-SA 4.0
2020-04-06T21:11:10.393Z
is the switch on the asset's volume set to "Assets in this volume have public URLs"?
Matthias
CC BY-SA 4.0
2020-04-07T22:10:34.050Z
Yes. I listed all attributes in the first code snippet box in my question.
Marco Camurri
<craft3><assets><url><image><404>
404 Error for assets where "Base URL" and "File system path" are different
# 404 Error for assets where "Base URL" and "File system path" are different

(Asked by: username_0 on 2020-04-02)

I am new to Craft 3 and I have seen similar questions asked many but never answered.
I want to store my images in a directory that is not public, yet I want them to be served correctly by Craft. The reason why I am doing this is that I work with shared disks for EC2 instances in AWS (Not S3) so I need to be able to mount shared volumes to store images for all the Front Ends to serve.
I am experimenting (without mounting a disk, to simplify) and I have a volume with:
name: images
handle: images
Assets in this volume have public URLs: on
Base URL: @web/somestuff
Volume Type: local folder
File System Path: /var/www/mydomain.com/imagesrepo

Note that the directory /var/www/mydomain.com/imagesrepo has 777 rights, images are uploaded correctly in the CMS, and even "image transform" correctly creates subdirectories and resizes images. I see the images thumbnails but, following the problem explained below, the image shows a broken  when I click on "preview".
Also note that in the directory tree, imagesrepo is outside the website root, at the same level with the "web", "config", etc... directories for Craft. (/var/www/mydomain.com/web is the website root)
I have installed "element api" and I am getting the URL of the image with 
$img->getUrl(),

and a "resized" version with 
$img->getUrl('largepic').

The result URLs I am getting are
https://mydomain.com/somestuff/2013-12-22-23.46.18.jpg
https://mydomain.com/somestuff/_largepic/2013-12-22-23.46.18.jpg

The URLs look correctly built and I would expect that, once called, Craft would fetch the image file with the actual disk location in /var/www/mydomain.com/imagesrepo and read it out to the front end. Instead I get a 404 page with 
HTTP 404 – Not Found – yii\web\NotFoundHttpException

and the whole stack trace, as if Craft was trying to find "somestuff" as a regular template.
Am I doing something wrong or is Craft not able to store assets in a physical location and serve them from a logical one?
P.s. Please do not tell me that there are drivers and plugins for AWS solutions. There are many reasons to store assets in physical locations that differ from the URL

**Tags:** craft3, assets, url, image, 404
> **Comments:**
> **username_1**: is the switch on the asset's volume set to "Assets in this volume have public URLs"?  
> **username_0**: Yes. I listed all attributes in the first code snippet box in my question.  

---

## 0 answers

