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?

Thanks.

1 Like

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.

3 Likes

@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.

5 Likes

@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

I am also using cpanel manager, can you tell me specifically how you can convert non-searchable pages to 404 pages from sparkle?

Ok @DaiDuong, firstly you need to create a 404 page in Sparkle.
Once done and uploaded to the hosting sever you need to gain access (via cPanel manager) to a file called “.htaccess”., or create one. Once in this folder add the following…

RewriteEngine on
#, redirect 404 to branded 404 page

ErrorDocument 404 /404.html

This will force any User errors onto your personalised 404 page.
Ok, I hope that helps! :slight_smile:

1 Like

My input here won’t apply to everybody as i run my own windows VPS but it may be useful for someone.

Windows servers using the .net framework allow configuration within web.config to redirect the default error pages to your own custom error pages within your website. Great. But i’ve found a better way.

When you publish you publish to httpdocs folder within the vhosts/yoursite folder. The vhosts/yoursite folder also contains other folders like cgi-bin, logs etc but it also contains an error_docs folder which contains all the error pages required. I think you can only access this folder via the server administrator account. Simply create a separate sparkle project (separate from your main website) for error pages, create your pages and title the same as the originals (or copy and change originals) and manually upload and copy to the error_docs folder (youcan’t use ftp for this) and voila, any and all errors result with your own design with the appropriate info.

It’s a shame this isn’t possible for single website hosting, although i can’t speak for linux.