shogitai
shogitai

Reputation: 1961

JS/CSS 404 not found using Slim Framework

I already read this question, but does not solved my case, even if is very similar.

I am using Slim framework.

This is my project structure. The Slim routing happens into the public folder.

enter image description here

The page templates/index.phtml needs some JS and CSS, but I get 404 not found.

My templates/index.phtml requires:

<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>

And I get (for example for the index.js):

Not Found

The requested URL /index.js was not found on this server.

Apache/2.4.18 (Ubuntu) Server at blah.blah.blah Port 443

Upvotes: 0

Views: 820

Answers (1)

David Shack
David Shack

Reputation: 131

I'm not very familiar with the Slim framework but I know you're using a router and a public folder which leads me to believe that it can't access index.js because it's out of scope. Perhaps try moving your script folder inside your public folder and see if that works! :)

Upvotes: 1

Related Questions