我正在为我的家庭作业设置一个本地Chevereto服务器(https://chevereto.com/free)。在成功下载整个应用程序后,我使用php -S localhost:8080运行它。然而,它只显示纯HTML文本,没有CSS和Javascript。当我在一个月前设置这个的时候,我没有这样的问题。
我对此做了一些研究,我认为这更多的是浏览器的问题。我用另一个文件中的javascript设置了一个php脚本。当我使用运行脚本时,网络选项卡显示对-S文件的请求返回的是index.php而不是javascript。我不确定这是不是一个类似的问题。
在我运行php -S并访问http://localhost:8080/之后,我打开控制台,发现以下警告:
<link rel="stylesheet" href="http://localhost:8080/lib/Peafowl/peafowl.css">
<link rel="stylesheet" href="http://localhost:8080/app/content/system/style.css">出现以下警告:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/app/content/system/install".
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/lib/Peafowl/install".还有这个错误:
Uncaught TypeError: $.each is not a function
at install:58
at install:58而来源显然有:
<script src="http://localhost:8080/lib/Peafowl/js/jquery.min.js"></script>
<script src="http://localhost:8080/lib/Peafowl/js/scripts.js"></script>那些文件就在我的电脑上。
在查看CSS/Javascript文件的请求时,我看到了以下内容:
General:
Request URL: http://localhost:8080/lib/Peafowl/peafowl.js
Request Method: GET
Status Code: 301 Moved Permanently
Remote Address: [::1]:8080
Referrer Policy: no-referrer-when-downgrade
Response:
Cache-Control: no-store, no-cache, must-revalidate
Connection: close
Content-type: text/html; charset=utf-8
Date: Tue, 16 Apr 2019 09:40:44 +0000
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Host: localhost:8080
Location: http://localhost:8080/lib/Peafowl/install
Pragma: no-cache
X-Powered-By: PHP/7.1.25有人知道怎么修吗?非常感谢。
发布于 2019-04-16 18:28:36
Chrome决定自己修复,可能是因为缓存过期了。正如上面提到的@Thum Choon Tat,它应该是一个类似于How long do browsers cache HTTP 301s?的问题。
https://stackoverflow.com/questions/55705344
复制相似问题