The project was working fine till i moved index.php
from project root to public
folder then moved css and js from public
to assets
folder here is how my project looks like now
i loaded the server with php -S localhost:8000
i get
Not Found
The requested resource / was not found on this server.
ignoring my .htaccess completely ! i even tried solutions like AllowOverride All
but still doesn't work so i typed php -S localhost:8000 -t public
now site loads but css/js doesn't work at all even inline style ! when i open console i get
The script from “http://localhost:8000/assets/js/main.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type
Loading failed for the <script> with source “http://localhost:8000/assets/js/main.js”
any ideas??
.htaccess is a configuration file for use on web servers running the Apache Web Server software. It means that when you start project with php -S localhost:8000
it simply ignores the routes written there.
What you can do:
php -S localhost:8000
inside public
folder or using -t
option to set the document root (will work for simple relative paths but not when you want to use Apache specific features like ModRewrite
)Good luck with your web development journey!
In index.php file do the below changes
<link rel="stylesheet" type="text/css" href="../assets/css/style.css">
<script src="../assets/js/main.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.