I am noticing my 404 page works fine when the wrong address is requesting something on the root level www.mywebsite.com/nopage.html
. But if I am going to a subpage that is not there then my 404 does not show correctly www.mywebsite.com/admin/nopage.html
. Is the only way to do this is set absolute paths to all the style sheets, links and images in your 404?
this is my http.conf entry:
ServerName www.mywebsite.com
DocumentRoot /var/www/currentsite
ErrorDocument 404 /404error.php
<Directory /var/www/currentsite>
Options -Indexes FollowSymLinks +Includes
AllowOverride all
Allow from all
Order allow,deny
</Directory>
Is there a way to send the browser to the 404 page verse calling the 404 down to where ever the user has ended up at?
Add <base href="http://www.mywebsite.com">
to the head
tag of your error page to make all relative urls resolve relative to www.mywebsite.com
(instead of www.mywebsite.com/admin
). I'm assuming that your error page is dynamically generated anyway, so if this error page needs to work on multiple domain names, it shouldn't be hard to add the correct domain name to the page on the server.