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

pippuccio76's avatar

Laravel on sub folder assets problem

hi , this is my project:

laravel
public_html
----------/public_laravel
-------------------------/index.php
-------------------------/.htaccess
-------------------------/assets

set .env as :

APP_URL=https://my_site/public_laravel

the system work but the assets are not ok , in my template i do :

<link rel="stylesheet" media="screen" href="/assets/assets_user/css/theme.min.css">

and the same on hosting but it must be :

<link rel="stylesheet" media="screen" href="/public_laravel/assets/assets_user/css/theme.min.css">

How can i set assets properly (without change template code ) ?

0 likes
2 replies
LaryAI's avatar
Level 58

One solution is to create a symbolic link from the public folder of your Laravel project to the assets folder in your public_html directory. This way, you can access the assets directly from the public folder of your Laravel project without changing the template code.

Here are the steps to create the symbolic link:

  1. SSH into your server and navigate to the public folder of your Laravel project:
cd /path/to/laravel/public
  1. Create a symbolic link to the assets folder in your public_html directory:
ln -s /path/to/public_html/assets assets
  1. Verify that the symbolic link was created successfully:
ls -l

You should see a new symlink named "assets" pointing to the assets folder in your public_html directory.

  1. Update your template code to use the new path to the assets:
<link rel="stylesheet" media="screen" href="/assets/assets_user/css/theme.min.css">

This should work without any issues, as the symlink will redirect the request to the correct path.

Note: If you're using a shared hosting environment, you may not have permission to create symbolic links. In that case, you can try using the "public_path" helper function in Laravel to generate the correct path to the assets. For example:

<link rel="stylesheet" media="screen" href="{{ public_path('assets/assets_user/css/theme.min.css') }}">
pippuccio76's avatar

@LaryAI

I add a {{url('/')}} to every link and work .

to store image file from upload my dir is : public_path().'/uploads/immagini_libri/'.$user->id.'/';

but public_path() is equal to /home/customer/www/my_site.eu/laravel_public/public

instead of: /home/customer/www/my_site.eu/laravel_public/

How can i set dinamically the public folder?

Please or to participate in this conversation.