HTTP 服务器及其目录
我有一个自定义 HTTP Web 服务器,每当我浏览它时,比如说: http://hotname:port 它会重定向到this:
服务器运行于: /home/user/app_web/bin/ start.pl
我有一个 HTML 目录,列于: /home/user/app_web/static
当服务器运行时,我发送给他的请求之一是一个 HTML,其正文具有此 img:
<img src="../static/page.html">
此页面加载正常,但其中的图像没有加载,位于: “/home/user/app_web/static/image/1.jpg”
当我查看页面已加载的 HTML 站点时,它看起来像:
http://hotname:port/base/../home /user/app_web/static/image/1.jpg"
我不知道我做错了什么,而且,我是网络新手。
谢谢,
I have a custom HTTP web server, whenever I browse to it, let say: http://hotname:port it redirects to this:
The server runs from: /home/user/app_web/bin/start.pl
I have a directory of HTMLs listed in: /home/user/app_web/static
while the server is running, one of the request I send to him is an HTML with a body having this img:
<img src="../static/page.html">
this page loads fine, but of the images in it, doesnt, which is in: "/home/user/app_web/static/image/1.jpg"
when I look at the HTML site the pages has loaded, it looks like:
http://hotname:port/base/../home/user/app_web/static/image/1.jpg"
I have no idea what am I doing wrong, also, I'm a newbie when it comes to web.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 HTML 文件位置是
图像位于
然后尝试将图像标签更改为:
URL 将相对于 HTML 文件计算出来。
(由于“static”是文件夹位置的一部分,而不是 URL,据我所知,您永远不必在 URL 中包含“static”。)
If the HTML file location is
and the image is in
Then try changing the image tag to:
URLs will be worked out relative to the HTML file.
(Since "static" is part of the folder location and not the URL, as far as I can see, you should never have to include "static" in the URL.)