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

gdubois's avatar

Laravel randomly not finding assets in public directory

I have installed laravel into a subdomain that is configured as a subdirectory of my main website.

laravel.example.com is set to point to laravel/public/ in my cpanel settings.

When I travel to the page, random elements like images, javascript, and css files do not load, and return a 404. Other times when I load the page those "missing" assets load just fine.

The file paths are not changing at any time.

Does anyone have an idea of what might be going on?

0 likes
3 replies
Cronix's avatar
Cronix
Best Answer
Level 67

If the urls for the assets are being generated properly (I'd view page source on a page that has this 404 happen to be sure), then it seems it would be at the webserver level and not laravel? When the browser requests http://somesite.com/images/someImage.png, that's going to the webserver and isn't processed by laravel at all. Are all of your assets using absolute urls vs relative?

jlrdw's avatar

Just a thought, I am guessing you uploaded to site via ftp. Is everything properly configured for production. Do you have compiled assets. I have never had assets not load.

And do you have laravel properly setup where the main laravel is above public_html.

Is it happening to all assets or just some.

WIsh I could help more, but look for the obvious first

Edit: Usually for shared, just put images and css, etc in a folder under public_html, then you can just use the asset helper. That is unless some of the images are private.

Note resources/assets is where compiled assets go.

gdubois's avatar

@Cronix I was thinking the same thing, and had opened a ticket with my hosting provider, but wanted to cover all of my bases.

I just heard back from them, and they were able to adjust something on their end and I am no longer getting any errors.

For future readers: in my case a typo while creating the subdomain in cpanel (which was edited to be fixed) was persisting, as their logs were showing some requests trying to access the old, misspelled folder that did not actually exist.

1 like

Please or to participate in this conversation.