【发布时间】:2021-09-07 20:28:13
【问题描述】:
我的应用程序具有以下文件结构
/App
/html
404.html
another.html
other.html
/css
main.css
.htaccess
index.php
我正在从index.html 和readfile() 发送other.html 文件。
所有 html 文件共享
main.css。
index.html 看起来像这样
<html>
<head>
<link rel="stylesheet" href="../css/main.css">
</head>
<body>
<a href="another.html">link</a>
</body>
</html>
我在 XAMPP 上运行它。与
http://localhost/App
我能够检索 index.html,但是当我点击链接时,我得到了 404.html,因为我写了 another.html 和 ../css/main.css,服务器正在寻找 http://localhost/App/another.html 和 http://localhost/css/main.css .这会导致 404.html 和 index.html 中的 CSS 混乱
我尝试通过将../css/main.css 替换为css/main.css 来解决此问题,但这会在遇到错误时导致404.html 中的CSS 混乱。我尝试的另一个尝试是/css/main.css,但同样没有运气服务器正在寻找http://localhost/css/main.css。
那么,我如何链接这些文件? .htacccess 中是否有任何可用配置可以说服务器将/(根)视为/App,所以如果有任何配置,那么我可以通过说/css/main.css、/html/another.html 和很快?还是有其他建议?
这是问题的视频:https://youtu.be/Qg7K8gOdyW0
【问题讨论】: