项目运行良好,直到我index.php
从项目根目录移至public
文件夹,然后将css和js从public
移至assets
文件夹,这就是我的项目现在的样子
我加载了服务器 php -S localhost:8000
我得到
Not Found
The requested resource / was not found on this server.
完全忽略我的.htaccess!我什至尝试了类似的解决方案,AllowOverride All
但仍然无法正常工作,所以我php -S localhost:8000 -t public
现在输入了网站加载的内容,但css / js甚至根本就没有内置样式!当我打开控制台时,我得到
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”
有任何想法吗 ??
.htaccess是一个配置文件,可在运行Apache Web Server软件的Web服务器上使用。这意味着,当您启动项目时,php -S localhost:8000
它只会忽略那里编写的路线。
你可以做什么:
php -S localhost:8000
在public
文件夹中运行或使用-t
选项设置文档根目录(仅适用于相对路径,但不适用于要使用Apache特定功能,例如ModRewrite
)祝您在Web开发过程中一切顺利!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句