我php -S localhost:8000
用作我的开发服务器。最后,我将使用 nginx。但是我的php服务器有问题。
root
|
|---/app
|
|---/index.html
|---/scripts
| |
| |---/main.css
|
|---/styles
|
|---/main.js
在我的app/index.html
我有:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles/main.css" type="text/css" />
</head>
<body>
<script src="scripts/main.js"></script>
</body>
</html>
当我在浏览器中打开页面时,localhost:8000/app
找不到 css 和 javascript。浏览器正在寻找localhost:8000/styles
相应的。localhost:8000/scripts
而不是localhost:8000/app/styles
相应的。localhost:8000/app/scripts
. 当我在没有服务器或使用 nginx 的情况下直接打开文件时,可以正确找到文件。所以php服务器改变了一些东西。这里发生了什么?
我在 Chrome 和 Firefox 中尝试过。两种浏览器中的行为相同。localhost/app
当我用( )打开网站时,nginx
一切都按预期工作。当我用localhost:8000/app
( php -S localhost:8000
) 打开网站时,找不到脚本和样式。它是具有相同文件根目录的相同文件。不同的行为从何而来?