0

this is my problem for a long year. every time I deployed the project always I add public sub directory to the css / images / JavaScript to the links. i will demonstrate here on the below the comparison.

Question: Is there way not to put the sub directory of public.?

Localhost VS Deployed project on apache.

Localhost:

<script src="{{asset('js/jquery.min.js')}}" crossorigin="anonymous"></script> 
<link href="{{ asset('datatables/dataTables.bootstrap4.min.css') }}" rel="stylesheet">
<img src="{{asset('storage/'.Auth::user()->profile_image)}}" class="img-profile rounded-circle" style="width:40px !important; height:40px !important;">

Production:

<script src="{{asset('/public/js/jquery.min.js')}}" crossorigin="anonymous"></script> 
<link href="{{ asset('/public/datatables/dataTables.bootstrap4.min.css') }}" rel="stylesheet">
<img src="{{asset('/public/storage/'.Auth::user()->profile_image)}}" class="img-profile rounded-circle" style="width:40px !important; height:40px !important;">

Thank you.

SoulAiker
  • 139
  • 1
  • 10
  • It sounds like the document root on your apache server is not properly set to the 'public' directory. Please see this answer on how to set your Apache root directory: https://stackoverflow.com/a/5891858/11182541. There might be easier ways to set the root directory if you are using a managed service to host your application – Eden Dowling-Mitchell Feb 27 '20 at 04:48
  • @EdenDowling-Mitchell i already point the root directory to the project folder. – SoulAiker Feb 27 '20 at 05:16
  • 1
    And do you point it to the 'public' folder within your project folder? It should be pointing to `/path/to/project/folder/public` – Eden Dowling-Mitchell Feb 27 '20 at 05:22
  • Does this answer your question? [How do I change the root directory of an apache server?](https://stackoverflow.com/questions/5891802/how-do-i-change-the-root-directory-of-an-apache-server) – Niket Joshi Feb 27 '20 at 05:47
  • @EdenDowling-Mitchell why do you mean for that? can you show to me the sample foldering? – SoulAiker Feb 28 '20 at 00:41

1 Answers1

0

No need /public.

<link href="{{asset('css/jquery-ui.min.css')}}" rel="stylesheet"/>