douan7601 2016-10-08 20:38
浏览 78

Laravel 5.2未找到css和js文件的异常

I have set up a laravel 5.2 project on a vps which uses cpanel.

I've configured the subdomain to point to the public folder within the subdomain folder and the app loads as expected.

However my login page is unable to load any assets - it comes up with an not found http exception for any of the assets.

for example: http://subdomain.domain.co.uk/css/app.css.

Once I log in the assets load correctly in all other pages - just not the log in one. If I then log out and log in again then the assets all load correctly.

Just not sure what's stopping the assets loading and for laravel to try and treat a path to a css file as a route.

Any help appreciated

Additional Information:

Here's the mark up for including the css:

<link rel="stylesheet" href="/css/app.css">

I've also tried:

<link rel="stylesheet" href="{!! asset('css/app.css') !!}">

This is identical to the pages that load the assets once logged in.

Folder Structure

Root/ (a few folders for brevity)

subdomain
    app/
        http/
            routes.php
    public/
        css/
            app.css
        js/
            app.js
    vendor

The server points to `subdomain\public' as normal laravel setup

It's still happening each time the cache is cleared and only corrects once logged in and only affects the login page

  • 写回答

1条回答 默认 最新

  • ds1379551 2016-10-16 21:12
    关注

    I am noticing that on L5.2 in the public directory it does not include a CSS folder.

    Here is the repo's folder for reference: https://github.com/laravel/laravel/tree/5.2/public

    This leads me to believe the assets need to be initially compiled via a gulp command which will run Laravel's Elixer and generate the assets.

    From the projects root folder run

    gulp or sudo gulp

    Take note, if you have not pulled in the assets you will have to run

    npm install or sudo npm install first. Here is the out the box NPM packages pulled for reference: https://github.com/laravel/laravel/blob/5.2/package.json.

    And if you cannot install using npm you will need to install node.js first.

    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大