Should we make our own 404 pages for our beautiful bespoke sites?


(Gabrielle Vickery) #1

I’m thinking that bespoke 404’s make more sense than having nothing there at all, but I’m a bit nervous as to how to implement properly.

I get that I’d need to make a new page, so call the folder 404 and the page index.html and design it within the existing layout and have an ‘oops’ sentence here, but there’s more to it isn’t there?

I’m sure I saw on one of Joe Workman’s blog a whole thing about having to go into the htaccess.
I just want to start setting up simple 404’s (also the same for other error pages or is 404 the main one?).

Can anyone advise?


404 Page-Creation and Location
(Will Woodgate) #2

If you want to customise the error message shown, login to your web hosts CPanel and use the Error Pages option to change the page. It will still be a white page, but you can put custom headings, text or links in there to help your users.

If you want to create a graphically-rich custom error 404 page that matches your RapidWeaver theme, then go ahead and create the page in RapidWeaver. If your CPanel does not provide the option to link to a custom 404 page, then you can add a redirect to the .htaccess file like this:

RewriteEngine on
ErrorDocument 404 /404.html

That code will redirect 404 to http://example.com/404.html where ‘example.com’ is your domain name. It’s a relative link so the full domain name is not shown in the .htaccess file.

For this second method, it would probably best to speak with your hosting company first to make sure it is something they are happy to support and that the code is correct. There can be variances in the exact code, between different web hosts.


(ian beattie) #3

Joe’s blog thing is a great place to start - i’d say go for it , do it as i’ve found many people bookmark a specific page and then revisit it 6 yrs later and under why its not there - duh . At least your own 404 page should have a message and a way for a visitor to find was they’re looking for .


#4

I am not expecting a lot of 404 traffic but even so I felt it was worth trying to produce something fun for the time it takes in RW. People can tend to feel annoyed if they hit an ugly 404 message so putting something friendly in there just eases the experience and should put them in a better mood when you direct them nicely to the correct place. Basically it shows you are thinking about the details.


(Gabrielle Vickery) #5

Thanks for the input. I’m going through @joeworkman’s tutorial on htaccess just to get started: https://joeworkman.net/tutorials/

I’ve gone to one of my sites ftp area so I can see all the files, but even with 'show hidden file’s ticked, I don’t actually see a .htaccess file listed. Are they not produced automatically when you make a site?


(Will Woodgate) #6

They are hidden files. See my post above. It might be something to speak with your hosting company about first. Not all web hosts support the use of .htaccess file. Some will routinely scan their systems and delete them!


(Brad Halstead) #7

All

Unfortunately, in my case, the host simply blocks the site when I add a properly formatted htaccess file… (BellNet - Canada), in other words, there is an issue with the website or configuration error, no pages served… grrrrr… Sometimes it takes the Host several days to figure out I’ve uploaded it but then it finds it and kills the site…

Trying to get the upper management to get a new host by February 7 when our Domain renewal comes up… am just a pion so have little faith this will occur :frowning:

Just a word of warning in addition to Wills…

Brad


#8

All I had to do was create a page in RW and call it 404.shtml. I didn’t mess around with htaccess.


(Doug Bennett) #9

It will vary by hosting company. Mine (little Oak) allows you to have one but does not have one by default. .htaccess files are text files (hidden by the dot). If your hosting company allows it you can add one. Might suggest you contact your hosting company look at help area (knowledge base) alot will have info on how to do an .htacesss file or redirect for not founds etc.


(Brad Halstead) #10

Might work if my host actually had it turned on lol

No SSI
No htaccess
No MySql
No HTTPS

Do have PHP capability though but only version 5.3.x ugh

A very limiting host meant for dummies… imho… (They prefer you build a page with their interface rather than FTP in combination with Software such as RapidWeaver…)

Hence why I made the request to change hosting companies to something a little more modern and better maintained.

Again, just a pion lol

Brad


(Will Woodgate) #11

@Turtle +1

I actually won a year’s worth of free hosting with a budget hosting company in the UK a few years back. I uploaded several in-progress websites I was developing for clients. All was working well - until I went back a few weeks later and found everything deleted and an account suspension notice! Initially I thought the hosting account had been hacked, but after numerous communications with their hopelessly bad support department; it transpired that some .htaccess files were found and that was a breach of ToS. So I never used them again. Since then through my line of work helping other RW users, I have encountered a few other hosting companies that are rather anti-htaccess too! But a majority are okay.

LittleOak, Chillidog and BlueHost appear to be the 3 most popular hosting companies with RW users, and all support .htaccess files and custom 404 pages.

My advice would be just to get an ‘okay nod’ from your hosting company, before making any changes to .htaccess files.


(Brad Halstead) #12

@willwood

Will be hosting with one of them for my personal site shortly… Thanks for the heads up.

Unfortunately, being the pion means I have no live connection to with either the domain registrar (can’t get CloudFlare going as an example) nor to Host - BellNet. The most I can do is use their interface and FAQ’s to do what I am allowed lol

Awesome feedback though this has been a great thread!

Brad


(Gabrielle Vickery) #13

Yes my hosting company says the following:

“.htaccess files aren’t supported on this server as it is a windows server and .htaccess are primarily used on linux servers. You can use a web.config file though if you need to make any configuration rules. A web.config is a configuration file contains rules which will change settings to IIS on the server. With this you can create rules to allow for certain file types, redirect certain pages or URLs etc. You will find the web.config in your website folder, where you can download and edit it.”

I’m a bit reluctant to do this because it’s all new, I’d like to do what Ashleykaryl has done and be done with it ;-).

Ashleykaryl, is that is? You just create the page and call it that? No htaccess or other code work needed?

Did you do the same for other error pages? ie 403.

Do we have to do individual pages for each error code?


(Richard Widman) #14

Interesting topic that I will consider doing for those errors that might come up. I don’t have many, as I have kept up my 301 redirects when I changed structures. I have about 300 lines of redirects. People still hit bookmarks or type in information from 15 years ago.


(Richard Widman) #15

After making the page, I looked through my host control panel and found the htaccess editor in the additional tools menu. once opened, it gave me the place to redirect the page to the one I created.


(scott williams) #16

So what causes the 404 not to work on pages below the root level?

xyz.com/gibberish works
xyz.com/giberisg/anotherpage does not… returns an un-styled (no css page)

Any ideas?

Thanks!

I figured it out…
I needed to have the full url to the 404 page in the .htaccess, not just /404.html


(Doobox Software) #17

The 404 page is being served instead of the requested page - look at
the location bar of your browser and you’ll see
http://domain/subdirectory/subsubdirectory/wrongname not
http://domain/404.htm

So the browser will resolve all relative URLs relative to the
incorrect URL.

You can use site root relative URLs instead of page relative URLs. This will always be resolved relative
to the root of the site and hence will always work regardless of where
the 404 document is returned.


(Doobox Software) #18

A better way if you are publishing with page relative url’s, would be to redirect to the 404 page, instead of having it served from the incorrect url.

So instead of having this in your htaccess file :

ErrorDocument 404 /404.html

Put this at the end of your htaccess file :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /404.html [L,R=301]

What does this do ?

The first line turns RewriteEngine on.
The second line sets a condition for the third line, ensuring that it’s a non-existant file and passing the requested filename (using a server variable (%{})).
The third line matches everything, replaces it with the path to your 404.html in the root, and sets two flags, the first (L) to stop any more rewrite rules from being applied, and the second (R=301) to force an external redirect using the error code 301.

Note: You need to make sure apache has ‘mod rewrite’ on and most web hosts do have this on by default otherwise you can ask your hosting provider if it’s not working.


New podcast episodes
(scott williams) #19

Thank You @Doobox,

What are the benefits of doing this -vs- just adding the full url of the 404 page to the .htaccess file?


(Doobox Software) #20

Simply put…If you do this :

ErrorDocument 404 /404.html

Then 404.html is served from the address the error was encountered (the incorrect url the user tried to visit).
This will cause and links that are relative to the page in this page /404.html to fail.

If you do this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /404.html [L,R=301]

This will redirect the browser to this actual page /404.html any time a user tries to access a page or file that does not exist.
This way it matters not if the links in /404.html are relative to the page or not, as it is being served from exactly where it was intended to be served from.