简体   繁体   中英

Deploying Laravel Project to subfolder on Hostinger

I just deployed my laravel project to hostinger but all the scripts don't load files from public folder

    <script src="/js/jquery.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/fonts/fontawesome/all.min.js"></script>
    <script src="/js/chartjs.js"></script>
    <script src="/js/camerajs.js"></script>

I tried to add public_path() to my scripts tags but it still leads to 404 page

It would be more accurate to use asset() helper instead of public_path() as this will give you the fully qualified path not the URL path .

You can take a look at this Laravel Helper .

t looks like you are using Laravel to build your web application and you are having trouble loading your JavaScript files from the public folder after deploying your project to Hostinger.

One possible issue could be that you are not including the base URL in your script tags. In Laravel, you can use the asset() helper function to generate the full URL for assets in the public folder. For example, you can update your script tags as follows:

<script src="{{ asset('js/jquery.js') }}"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
<script src="{{ asset('fonts/fontawesome/all.min.js') }}"></script>
<script src="{{ asset('js/chartjs.js') }}"></script>
<script src="{{ asset('js/camerajs.js') }}"></script>

This will generate the full URL for each of your JavaScript files, including the base URL of your application.

If you are still having trouble loading your JavaScript files after making this change, there may be other issues at play. Some things you could try include:

  • Checking the file paths and making sure they are correct
  • Checking the permissions on your files and directories to ensure they are readable by the web server
  • Checking the logs for any error messages that may provide more information about the problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM