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.

    评论

报告相同问题?

悬赏问题

  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码