Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Demers94's avatar

Path to storage from a view

I've setup my server with a virtual host and an alias, to redirect the request from /mods to /var/www/html/mods/public (to get rid of the /public in the URL).

First, I would get 500 errors when trying to change page, I found out that I had to change the RewriteBase in the .htaccess in the /public folder, like so :

[...]
RewriteEngine On
RewriteBase /mods/
[...]

Now the routing part works, but I wasn't able to require any assets (CSS, JS, images) that were in the public folder.

This is the code I was using :

<link rel="stylesheet" href="/mods/public/scss/main.css">

I had to change it to this :

<link rel="stylesheet" href="{asset('scss/main.css')}">
(with two curly brackets on each side, the forum won't display it otherwise)

Now it works, I can load my images, CSS and JS files, but I can't load any image or file that is in the storage folder.

This is the path I'm using :

 <img src="/mods/storage/mods/1/image.png" alt="" >

I get a 404 in the console because it can't load the image.

How can I load the files/images in the storage folder from my views? I tried using the storage_path() helper, but it doesn't work.

0 likes
5 replies
Snapey's avatar

Because you have got rid of mods by making /mods/ the root of the site.

based on your example, your storage should be found at <img src="/storage/mods/1/image.png" alt="" >

Demers94's avatar

@Snapey I tried that updated path but it still doesn't work.

If I look at the path generate from Laravel's assets() helper function, this is the path for the CSS (that works) :

/mods/scss/main.css

The scss folder is in the /public directory, so I tried this :

/mods/../storage/...

as my path but it still won't work.

Demers94's avatar

@Snapey

This is the config :

 Alias /mods/ "/var/www/html/mods/public/"
<Directory "/var/www/html/mods/public/">
    Order allow,deny
    AllowOverride All
    Allow from all
    Require all granted
</Directory>

@bestmomo

I tried that, the path translates to this :

/var/www/html/mods/storage/mods/2/images/4.png

It won't work though, even if the specified file does exist at that path.

Please or to participate in this conversation.