V9द's avatar
Level 3

After remove public from url unable to access css and js

I want to upload my laravel project in sub folder on server. But after removing public from the url i am unable to access js and css file. I am using Laravel 5.5. I saw many question regarding to this topic. But I did not found soloution of this problem for me. Please help

0 likes
10 replies
arukomp's avatar

have a look at your app.blade.php master layout template. See if any of the css/js urls need to be changed.

arukomp's avatar

You should be accessing your resources dynamically like this:

<link rel="stylesheet" href="{{ asset('assets/plugins/select2a/css/select2-bootstrap.min.css') }}">

An even better way of doing it would be to use Laravel Mix

This way you would combine all of your vendor CSS into one vendor.css file and you'd only need to include that one file in your template. Plus, fewer files means faster downloads for the user. Same goes for JS files

1 like
arukomp's avatar

I thought you removed public from your url and you could access your site via http://mysite.com/

What did you really mean by "removing public from the url " ? Your domain root is still pointing to the /laravelapp/public/ folder, right?

V9द's avatar
Level 3

@nanadjei2 I want upload webiste on server in subfolder, So i have to remove public from url but website css and js are in public folder so thats are not coming.

arukomp's avatar

Make sure you're linking your domain to Laravel's public folder.

laravelapp/app
laravelapp/bootstrap
laravelapp/artisan
...
laravelapp/public   <--- your domain needs to point here!

atiq0008's avatar

I have same problem I can fix it from .env file. you just need to add APP_URL with public in this and also add ASSET_URL, like this. APP_URL=http:"//localhost/my-project/public" ASSET_URL="${APP_URL}" hope so this will resolve your problem

Please or to participate in this conversation.