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

dsgrs26202
dsgrs26202 嗨-尝试了工匠的命令,没有一个有所作为。我仍然为所有资产的页面获取NotFoundHttpException
大约 4 年之前 回复
dongliao1860
dongliao1860 尝试phpartisanview:clear,phpartisancache:clear和phpartisanroute:clear
大约 4 年之前 回复
douqin1932
douqin1932 你可以粘贴它们的包含方式以及从工作页面进行比较吗?
大约 4 年之前 回复
doudinghan8319
doudinghan8319 不-它是一个没有布局的独立页面,但它确实使用了一些网站资源,如常见的css文件和jquery文件等
大约 4 年之前 回复
doushi3819244
doushi3819244 您的登录视图是否扩展了相同的主布局?
大约 4 年之前 回复

1个回答



我注意到在公共目录中的L5.2上它不包含CSS文件夹。</ p>

以下是repo的文件夹供参考: https://github.com/laravel/ laravel / tree / 5.2 / public </ p>

这让我相信资产需要通过 gulp </ code>命令进行初始编译,该命令将运行 Laravel的Elixer 并生成资产。</ p>

从项目根文件夹运行</ p>

gulp </ code>或 sudo gulp </ code> </ p>

请注意, 如果您尚未提取资产,则必须首先运行</ p>

npm install </ code>或 sudo npm install </ code>。 以下是NPM包装盒的参考: https://github.com /laravel/laravel/blob/5.2/package.json 。</ p>

如果无法使用 npm </ code>进行安装,则需要安装 node.js 。</ p>
</ div>

展开原文

原文

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.

douwei8672
douwei8672 嗨 - 这取决于你的公共回购意味着什么。 目前子域指向公共文件夹。 为清楚起见,我将为问题添加文件夹结构。 所有资产都包含在域中,而不是托管在其他地方
接近 4 年之前 回复
dongyue0263
dongyue0263 这碰巧是偶然的公开回购吗?
大约 4 年之前 回复
doutuo3575
doutuo3575 不,这不是问题 - css文件夹和公共文件夹中存在的所有资产。 资产是用elixir编译的,作为我构建的一部分,但这不是导致这个问题的原因。 资产的路径被视为创建错误的路径 - 但是一旦登录并重新加载页面,资产就会正确加载。
大约 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐