【问题标题】:000webhost don't show my css, js, image files000webhost 不显示我的 css、js、图像文件
【发布时间】:2021-08-23 08:22:56
【问题描述】:

我的 Laravel 项目在我的本地主机上正常运行,但是当我在 000webhost 上上传时,它只显示 html 数据,而 css、js、图像文件不显示。这是一个关于css文件的例子,我用它来链接css文件:

<link href="{{asset('public/frontend/css/bootstrap.min.css')}}" type="text/css" rel="stylesheet">

这是我的文件结构

-app
-bootstrap
-config
-database
-public
 --frontend
  ---css
   ----bootstrap.min.css
   ----some files css in here
  ---fonts
  ---images
  ---js
-public_html
-resources
 --views
   ---index.blade.php
-routes
-storage
...

当我运行时出现 2 个错误:

拒绝应用样式来自 'https://...000webhostapp.com/public/frontend/css/bootstrap.min.css' 因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并启用严格的 MIME 检查。

加载资源失败:服务器响应状态为404()

所有css、js、图片文件都有2个错误。

【问题讨论】:

  • 一般来说,您在引用资产时不需要包含public/,因为该目录应该被定义为您域的网络根目录。你的主页地址是什么? (https://...000webhostapp.com/https://...000webhostapp.com/public/)在.env 文件中设置为APP_URL 的内容是什么?
  • 我尝试擦除所有public/,但它仍然不起作用。我的主页是https://...000webhostapp.com/APP_URLhttp://localhost

标签: laravel


【解决方案1】:

解决了!!我真的不明白,但我只是将public 文件夹移动到public_html 文件夹中,它就可以了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-28
    • 2018-08-06
    • 1970-01-01
    • 2015-08-07
    • 1970-01-01
    • 2010-10-15
    • 2011-04-15
    • 1970-01-01
    相关资源
    最近更新 更多