【问题标题】:laravel 5.3 hosting issue - not loading csslaravel 5.3 托管问题 - 不加载 css
【发布时间】:2018-10-08 23:42:35
【问题描述】:

我正在尝试让我的 laravel 应用程序在 godaddy 上运行,我将公共文件夹内容移动到根 public_html 文件夹并且应用程序已启动并运行,这里是 link,css 文件和图像未加载。这是为什么呢?

当我在浏览器上使用 inspect element 时,我的 css 文件链接给出了写入路径。但并没有真正起作用。

这里是链接到 css 文件的代码:

<link href="{{ URL::asset('css/style.css')}}" rel="stylesheet">

我也试过了:

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

和:

<link href="{{ HTML::style('css/style.css')}}" rel="stylesheet">

没有一个对我有用,但在 localhost 上工作正常

我的图片代码链接图片:

{{ URL::asset('images/logo.png')}}

【问题讨论】:

  • 您是否将css 和image 文件夹放入public 文件夹中?
  • 是的,也不行
  • 你把 index.php 文件放在哪里了?
  • 在托管 'public_html' 文件夹中
  • 尝试添加{{ asset('public/css/style.css')}}

标签: php html laravel-5 hosting


【解决方案1】:

我认为这不是托管问题,您的 style.css 不存在于 css 文件夹和 images 文件夹中的图像。上传这些文件。 如果您在控制台中看到,您会发现 404 not found 错误。

style.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
logo.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
slide1.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
slide2.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
financial.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
slide3.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
/favicon.ico:1 Failed to load resource: the server responded with a status of 404 (Not Found)
style.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)

【讨论】:

    【解决方案2】:

    在托管时您应该在托管时键入来自 public_html 文件夹的完整路径的问题

    【讨论】:

      【解决方案3】:

      如果文件存在但显示 404 错误 Laravel link href invalid path

      ,这是另一种处理丢失 js 和 css 文件的方法

      【讨论】:

      • 这应该在评论框中或标记为重复,因为这不能提供问题的答案
      • 这是对问题的回答。问题不是缺少文件,而是与共享主机缺少文件路径有关。
      猜你喜欢
      • 2017-05-12
      • 2017-06-21
      • 2021-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-07
      • 2017-04-28
      相关资源
      最近更新 更多