![](/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.