[issue] Possible All Way To Change Asset Path And Add Public To Asset Path In Laravel

  • 25-06-2022
  • 708
  • Laravel 9
  • Haresh Chauhan

Laravel default asset path includes the public folder but if your changed your root path and want to add prefix in your asset URL and want to change your asset path then this post will help you with various ways to change your asset path in your laravel application.

There are many ways to change asset paths and these ways I have discussed in this post how to use and change asset paths.

You can add prefix path or your modify to the directory with the same asset() function with a different URL or path.

Change From (.env)

Add below code in your .env file.

ASSET_URL=public

After adding this path in your .env file run the below command.

php artisan config:cache

This command will clear your config cache from the application.

Change In app.php

Goto in your app.php file below the given path and change your asset URL in this file given attribute name with asset_url.

config/app.php

'asset_url' => env('ASSET_URL', 'https://www.abc.com/public'),

Prefix Add-In Assets

asset('public/css/custom.css');

Default index.php Root Path Change And Remove Public From The Url

Laravel Remove index.php From URL


We always thanks to you for reading our blogs.


dharmesh-image

Dharmesh Chauhan

(Swapinfoway Founder)

Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us

haresh-image

Haresh Chauhan

(Co-Founder)


We Are Also Recommending You :