Search code examples
laravellaravel-5.5

Image path is not working after removing public from URL in laravel 5.5


My images are working fine in anchor text. but when I remove public from URL (by putting .htaccess in root directory) Image path is not working.

<a href="new_profile.php" class="thumbnail">
  <img src="admin_images/noti.png" alt="..."><strong>Profile</strong>
</a>

This admin_images folder is in Public folder.


Solution

  • url() generates an absolute URL to the given path and asset() generates a URL to an application asset.

    Here the code:

    <img src="{{asset('admin_images/noti.png')}}" alt="..."><strong>Profile</strong>

    -will do the job. Otherwise you will have an external error(maybe from your .htaccess).

    The asset function generates a URL for an asset using the current scheme of the request