404 Error Page... Thoughts?

Hi @duncan
Just want to ask your expertise! What are your thoughts on a 404 page and Sparkle? Do you think we need to create a 404 page in Sparkle before we publish our project?


there isn’t a uniform handling of 404 pages on servers, so there’s no one size fits all advice on this.

The best bet is to configure the server so when a page is not found it redirects to say /404.html, then create the not found page in Sparkle and give it the “404.html” custom filename.

If you don’t set up the error page with redirection, when someone follows a link to /whatever/bogusaddress.html, the server will serve the error page from the /whatever/ folder, and since Sparkle pages all contain relative URLs, all the links and image references in the page will break.

1 Like

@duncan, Thank you Duncan for your help on this and what you say makes sense! :slight_smile:

I have recently done something with error Pages in Sparkle.
I have generated an error page in Sparkle 404.html and with a bit of htaccess it works perfect.

My site is currently a construction site and not available for the public,
(I have it online on my webserver but it‘s password protected through htaccess)

1 Like

@Fehmarnufaktur, That’s great to hear. How did you go about with your htaccess (php?) to redirect to your 404.html?

Hi, here is my htaccess file:

RewriteEngine On
#Optional: RewriteCond %{HTTP_HOST} www.domain.tld$ [NC,OR]
#Optional: RewriteCond %{HTTP_HOST} domain.tld$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]
ErrorDocument 404 /404.html

The last part is important for the redirect to my error document.
I have made a new Page in Sparkle and named it 404.html

That‘s all :grinning:

You only Need the part with error document.
The rest has other functions.


@Fehmarnufaktur, Hey a big thank you for sharing! :slight_smile:

1 Like

Thank you for that nugget!

1 Like

@Fehmarnufaktur, I first tried to see if the cPanel allowed this redefining of a new 404 page but from what I saw no… So I tried your method “ErrorDocument 404 /404.html” and I got it to work straight away!!! So a big thank you! :slight_smile:

1 Like

You are welcome :blush:

It is good to hear, I love to work with htaccess myself