avatar

麦兜的小站

MDO.INK

  • 首页
  • 随笔
  • 知识库
  • 归档
  • 动态
  • 标签
  • 关于
Home Laravel file 404 Not Found
文章

Laravel file 404 Not Found

Posted 2025-06-24 Updated 2025-07- 13
By power 已删除用户
10~13 min read

When working with Laravel, you may encounter a situation where an image or a file that loads perfectly fine on your local development environment doesn’t load on your hosting server. This is a common issue, especially when dealing with storage links and filesystem permissions. If you’ve run into this problem, here’s a step-by-step guide to fix Laravel Storage 404 Not Found.

Step 1. Delete and Recreate the Symlink

One of the most common causes of this issue is a broken or misconfigured symlink between your public directory and your storage directory. To fix this, you can delete the existing symlink and create a new one. If you are using hosting, you can use SSH to do this. If you don’t know how to do ssh on hosting, read this article.

Remove the existing symlink

Create a new symlink

This will ensure that the symlink is correctly created and points to the right directory, allowing your images to be accessed via the URL.

Step 2. Verify the Symlink Manually

If you have SSH access to your server, you can manually inspect the symlink to ensure it’s pointing to the correct location.

Check the symlink

This command will display the target path of the symlink. Make sure it points to ../storage/app/public.

Step 3. Check File and Directory Permissions

File and directory permissions are another common culprit. If the web server cannot access the necessary files due to restrictive permissions, the images won’t load.

Set the correct permissions

chmod -R 775 storage
chmod -R 775 public/storage

Ensure that the web server user (often www-data or apache) has adequate permissions to read the files within these directories.

4. Test the URL

After recreating the symlink and checking permissions, attempt to access the image directly through the browser.

Test the URL

https://yourdomain.com/storage/your_folder/file_name.png

If the image still doesn’t load, the problem might lie in your server configuration or filesystem settings.

5. Verify .env and filesystems.php Configuration

Your .env file and filesystems.php configuration play a critical role in how Laravel handles URLs and file paths. Ensure that your .env file is correctly configured with the appropriate APP_URL:

Check your .env file

APP_URL=https://your-site.com

Next, confirm that the filesystems.php configuration is correctly set up:

Verify filesystems.php

'public' => [
    'driver' => 'local',
    'root' => storage_path('app/public'),
    'url' => env('APP_URL') . '/storage',
    'visibility' => 'public',
],

Still Having Issues?

If after following all these steps your images are still not accessible, it may be time to contact your hosting provider. There could be server-level restrictions or configuration issues preventing the symlink from functioning properly.

Access issues like these can be frustrating, but with a systematic approach, they’re usually solvable. By ensuring your symlinks are correctly set up, permissions are appropriately configured, and your environment variables are in order, you should be able to get your images loading as expected on your hosting environment.

知识库
License:  CC BY 4.0
Share

Further Reading

Jul 31, 2025

如何实现接口幂等性

通俗的说,用户在系统中有操作,不管重复多少次,都应该产生一样的效果或返回一样的结果的。 幂等性的概念 幂等(Idempotent)是一个数学与计算机学的概念,常见于抽象代数中。 f(n)=1^n//无...

Jul 19, 2025

10个npm工具包

有了npm之后,前端人员真的是过上好日子了。我们可以直接把别人写好的工具包拿来用,非常的方便。 1.day.js-轻量日期处理 npminstalldayjs importdayjsfrom'd...

Jul 17, 2025

How to set up PHP7.4 on MacOS.

Thisisallverywellandgood.Apartfromonesmallinsignificantthing… TheversionofPHPinuseiscurrently7.4. Th...

OLDER

一条命令设置文件夹755,网页文件644权限

NEWER

express使用node-schedule实现定时任务

Recently Updated

  • 如何实现接口幂等性
  • 10个npm工具包
  • How to set up PHP7.4 on MacOS.
  • Automa:一键自动化,网页数据采集与工作流程优化专家Automa:解锁自动化
  • Mac 下用 brew 搭建 LNMP

Trending Tags

thinkphp clippings

Contents

©2025 麦兜的小站. Some rights reserved.

Using the Halo theme Chirpy