![](/img/trans.png)
[英]IntelliSense doesn't work for files in Public folder in Node.js solution in VS 2015
[英]Style and js doesn't work after changing project entry point to public folder
该项目运行良好,直到我将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
now 站点加载,但 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 ZC6E190B2846334348EZ9E5DZ 服务器软件的 web 服务器上使用。 这意味着当您使用php -S localhost:8000
启动项目时,它只会忽略那里写入的路由。
你可以做什么:
public
文件夹中运行php -S localhost:8000
或使用-t
选项设置文档根目录(适用于简单的相对路径,但不适用于 Apache 特定功能,如ModRewrite
)祝您的 web 开发之旅好运!
在 index.php 文件中进行以下更改
<link rel="stylesheet" type="text/css" href="../assets/css/style.css">
<script src="../assets/js/main.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.