Apache 版本是 2.4。在 httpd.conf 中,有一个带有自定义 404 页面的虚拟服务器:
<VirtualHost *:80>
ServerAdmin **
DocumentRoot /var/www/html/**
ServerName www.**
ServerAlias **
ErrorDocument 404 /404.html
</VirtualHost>
404.html文件在网站的根目录下,里面有来自子目录“imgaes”(<img src="images/some_img.jpg" />
-relative image links)的相关链接和图片。
如果对不存在页面的请求是在根目录中完成的,如www.website.com/not_found
,则 404.html 上的图像显示良好,但如果在子目录中请求www.website.com/sub_sir/not_found
不存在的页面,如,则所有图像和链接都会损坏。
有没有办法告诉 Apache 重定向到 404 页面,就像它在根目录上一样,而不是像当前请求的目录一样显示它?