Jump to content

404 .htaccess problem


Anton_Aligned_Assets

Recommended Posts

Hi guys,

 

I was wondering whether I could get some assistance with a problem I'm having:

 

I've started looking after my company's website and have recently set up a custom 404 error page for it.

 

My .htaccess file reads: ErrorDocument 404 /404.html

 

The problem I've got is that it's not working properly all the time.

 

When the incorrect URL looks like this: www.companydomain.com/xxx everything works fine, but when an additional forward slash gets added in it stops working properly , for example if the URL looks like www.companydomain.com/xxx/yyy. The 404 goes through, and it tries to load the page, but all of the formatting to the text goes out the window and none of the linked images on the page, such as the header on the top, gets pulled through - instead of the images I get the black box with an X in it.

 

What have I done wrong, and what do I need to do so that the correct 404 error page comes up for any combination put after the domain name.

 

If anyone has any suggestions i'd be very grateful.

 

Thanks!

Link to comment
Share on other sites

Your 404 page will need an absolute link to the stylesheet. You can do that by prepending the URL with a / to indicate that it's always relative to the site root and not the file's current location.

 

<link href="/css/style.css" rel="stylesheet" type="text/css">

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...