自定义 404 页面上的相对链接

Est*_*rla 3 apache .htaccess http-status-code-404

我的网站中有一个个性化的 404 错误页面,其中包含

ErrorDocument 404 404.htm
Run Code Online (Sandbox Code Playgroud)

在我的.htaccess

问题是,如果您输入www.mydomain.com/whatever/whatever2.html,它会正确显示 404 页面,但链接都已损坏,例如href="property.php"指向 的链接www.mydomain.com/whatever/property.php,这也是 404 错误。

如何在不将所有路由更改为绝对路由的情况下解决此问题?

anu*_*ava 5

您可以将其添加到<head>页面 HTML: 部分<base href="/" />,以便从该基本 URL 而不是从当前页面的 URL 解析每个相对 URL 。