使用Slim Framework找不到JS / CSS 404

时间:2018-04-04 13:03:32

标签: html dependencies resources slim

我已经阅读了this个问题,但即使非常相似,也没有解决我的问题。

我正在使用Slim框架。

这是我的项目结构。 Slim路由发生在public文件夹中。

enter image description here

页面templates/index.phtml需要一些JS和CSS,但我找不到404。

我的templates/index.phtml要求:

<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>My WebSite</title>
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="style/global.css">
    <script src="bower_components/jquery/dist/jquery.min.js"></script>
    <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="script/index.js"></script>
</head>

我得到了(例如index.js):

  

未找到

     

在此服务器上找不到请求的URL /index.js.

     

Apache / 2.4.18(Ubuntu)服务器在blah.blah.blah端口443

1 个答案:

答案 0 :(得分:1)

我对Slim框架不是很熟悉,但我知道您正在使用routerpublic文件夹,这让我相信它无法使用访问index.js因为它超出了范围。也许尝试将script文件夹移到public文件夹中,看看是否有效! :)