【发布时间】:2016-11-10 10:25:18
【问题描述】:
我对 apache 还是很陌生。我想创建一个由 apache 托管的网站,所以这就是我所做的: 我在 /var/www/html 中创建了一个名为“test”的新文件夹 我将 index.html、js 和 css 文件放在新文件夹中
然后我尝试通过localhost/test访问网站,显示html页面,但是无法访问js和css文件。在控制台中显示“NetworkError:404 Not Found - http://localhost/main.js” 为什么 url 中缺少“/test”?
我的 index.html 有 <script type="text/javascript" src="main.js">
谁能弄清楚是什么问题?
更新
我检查了 dir.conf 并添加了“DirectorySlash on”,现在它看起来像:
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
DirectorySlash on
</IfModule>
我注意到当我尝试访问 http://localhost/test 时,它会在末尾添加“/”,但我仍然遇到同样的错误。
【问题讨论】:
-
“我注意到当我尝试访问 localhost/test 时,它会在末尾添加 '/',但我仍然遇到同样的错误。” — 在其他条件相同的情况下:这不会发生。您需要提供一个minimal reproducible example,其中包含足够的信息来重现问题。