I have a 404 personalized error page in my web, with
ErrorDocument 404 404.htm
In my .htaccess
The problem is, if you type www.mydomain.com/whatever/whatever2.html it shows the 404 page correctly, but the links are all of them broken, for example a link to href="property.php" points to www.mydomain.com/whatever/property.php, that is a 404 error too...
How can i fix this without changing all the routes to absolute routes?
Thank you
答案 0 :(得分:3)
You can add this in the <head>
section of your page's HTML: <base href="/" />
so that every relative URL is resolved from that base URL and not from the current page's URL.
答案 1 :(得分:1)
Instead of using relative paths like:
href="property.php"
Try using absolute paths like:
href="http://www.example.com/path/to/property.php"
答案 2 :(得分:0)
<base href="/">
不适用于Google Adsense / Analytics。零分部。
因为错误404页面必须能够从我的404.php仅包含的任何URL中运行
<?php
header("Location: http:/homepage.de");
?>
通过这种方式,它可以重新定位到基本URL。