Page 1 of 1
Custom 404 pages.. making them work...
Posted: Sat Apr 23, 2022 8:17 pm
by kreemerz
Just a quick question on how to get my custom 404 page to show up in my site.
Is there some trick? I recall having a host years ago where all I had to do was design the page and rename it "404.html" and it would work like it was supposed to (show up when I tried to access a nonexistent page.
Apparently, that's not the case anymore.
Any ideas?
Re: Custom 404 pages.. making them work...
Posted: Sat Apr 23, 2022 8:31 pm
by WWBman
You can name your error page whatever you like.
It must not have any external css style sheets so the Tools > Option > HTML > CSS must be unticked.
There should be an entry in the .htaccess file on the server as follows:
ErrorDocument 404 /errorpages/error404.php
where /errorpages/error404.php is where your error page is and can be anything you like.
Re: Custom 404 pages.. making them work...
Posted: Sat Apr 23, 2022 9:15 pm
by wwonderfull
kreemerz wrote: ↑Sat Apr 23, 2022 8:17 pm
Just a quick question on how to get my custom 404 page to show up in my site.
Is there some trick? I recall having a host years ago where all I had to do was design the page and rename it "404.html" and it would work like it was supposed to (show up when I tried to access a nonexistent page.
Apparently, that's not the case anymore.
Any ideas?
In your case I think it should be more like
ErrorDocument 404 /404.html
If you have a single 404 error page along with your normal pages
Re: Custom 404 pages.. making them work...
Posted: Sat Apr 23, 2022 10:24 pm
by kreemerz
wwonderfull wrote: ↑Sat Apr 23, 2022 9:15 pm
kreemerz wrote: ↑Sat Apr 23, 2022 8:17 pm
Just a quick question on how to get my custom 404 page to show up in my site.
Is there some trick? I recall having a host years ago where all I had to do was design the page and rename it "404.html" and it would work like it was supposed to (show up when I tried to access a nonexistent page.
Apparently, that's not the case anymore.
Any ideas?
In your case I think it should be more like
ErrorDocument 404 /404.html
If you have a single 404 error page along with your normal pages
Hmm... still not showing up... should I edit the htaccess file within Cpanel?
or create my own htaccess file?
Re: Custom 404 pages.. making them work...
Posted: Sat Apr 23, 2022 10:31 pm
by WWBman
You should edit the .htaccess file.
Re: Custom 404 pages.. making them work...
Posted: Sat Apr 23, 2022 10:36 pm
by kreemerz
WWBman wrote: ↑Sat Apr 23, 2022 10:31 pm
You should edit the .htaccess file.
And just add the line "ErrorDocument 404 /
mywebsite.com/error/404.php" line?
Re: Custom 404 pages.. making them work...
Posted: Sat Apr 23, 2022 10:45 pm
by WWBman
If your error page is 404.html in the root then it should be as wwonderfull stated.
You don’t need to include your website, just the error page.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 12:49 am
by KingSparta
On Godaddy, the extender is not HTML,it is ".shtml"
My 404 page
https://myaagrapevines.com/404.shtml
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 1:47 am
by BaconFries
On Godaddy, the extender is not HTML,it is ".shtml"
@KingSparta Now not judging you in anyway what so ever...but can you please show in any documentation that you cannot use .html, .php for the 404 but only .shtml when using GoDaddy.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 2:14 am
by kreemerz
https://privatebin.support-tools.com/?a ... VEBMGA4ro=
I wish this forum had a way to display images...
My page works but the text and everything is all jumbled up... doesn't look anything like the orginal.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 2:21 am
by KingSparta
BaconFries wrote: ↑Sun Apr 24, 2022 1:47 am
On Godaddy, the extender is not HTML,it is ".shtml"
@KingSparta Now not judging you in anyway what so ever...but can you please show in any documentation that you cannot use .html, .php for the 404 but only .shtml when using GoDaddy.
I was not saying that, only that GoDaddy's default is shtml
I should have been more clear.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 2:48 am
by BaconFries
My page works but the text and everything is all jumbled up... doesn't look anything like the orginal.
From looking at the image it shows that not all files are uploaded this may be the css files or even the jquery or any javascript used.
You cannot upload images directly to the forum for security reasons. But you can still display them by wrapping them with
I would suggest you keep them in the simplest way such as
Code: Select all
[img]https://www.yoursiteurl.com/yourimg.jpg[/img]
Uploading to your own site or any of the free image hosting sites.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 2:57 am
by kreemerz
So it does need to be a PHP file?
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 3:11 am
by BaconFries
Confused now....what is it your asking is it
why your page looks jumbled (answered) or
should the 404 page extension be .php or .html? if you use .php then you will need to include a header or a
http response code
Code: Select all
<?php http_response_code(404); include('your404.php'); // provide your own HTML for the error page die();?>
If using just .html then see previous answers on the use of using a .htcaccess file for this
I have also made it so that your image is displayed in your thread using the following site imgbb.com using the Embedded code-> BBcode full link with the url generated.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 3:34 am
by kreemerz
I may have confused myself.
All I wanted to do was build a custom 404 page. I already designed it and uploaded it.
http://www.kreemerz.com/error/404.html
Now, my host has a Cpanel that unfortunately is the standard for mamaging your site. I'm confused on whether I need to go into the
'Error Pages' section and edit that file or go to the
File Manager and edit that file.
I believe someone earlier said that I needed to change my custom 404 page as a PHP file. But sounds like that's not even necessary or just an option.
I was trying the find the most easiest way to do this.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 5:13 am
by wwonderfull
404 pages not so much needed if you have a small website 1-5 page website where you change pages yearly and not monthly or daily. Websites where people upload pages and delete frequently need it the most. You can put a simple, beautiful and artistic way of displaying 404 error page. I personally used 404 error page with simple html page and a beautiful illustration.
For the php error page as @bacon has given the code, you might have to do that I can assure on that. But if you as you stated want everything simple then you can do an html 404 error page depending on your needs you should implement. So it would be your decision 1st hand.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 6:01 am
by kreemerz
wwonderfull wrote: ↑Sun Apr 24, 2022 5:13 am
404 pages not so much needed if you have a small website 1-5 page website where you change pages yearly and not monthly or daily. Websites where people upload pages and delete frequently need it the most. You can put a simple, beautiful and artistic way of displaying 404 error page. I personally used 404 error page with simple html page and a beautiful illustration.
For the php error page as @bacon has given the code, you might have to do that I can assure on that. But if you as you stated want everything simple then you can do an html 404 error page depending on your needs you should implement. So it would be your decision 1st hand.
I guess the issue I'm having is how to make it work.. how do I get it to show up when you access a nonexistent page.
With the code
<?php http_response_code(404); include('/error/404.php'); // provide your own HTML for the error page die();?> , do I place this in the same file (error/404.php)? or does it go in the
.htaccess file?
Do I need this line of code as well, "
ErrorDocument 404 /mywebsite.com/error/404.php" line?
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 6:44 am
by wwonderfull
I guess the issue I'm having is how to make it work.. how do I get it to show up when you access a nonexistent page.
With the code <?php http_response_code(404); include('/error/404.php'); // provide your own HTML for the error page die();?> , do I place this in the same file (error/404.php)? or does it go in the .htaccess file?
Do I need this line of code as well, "ErrorDocument 404 /mywebsite.com/error/404.php" line?
For the php code I can say our dear moderator @bacon can assist you with his grateful advice on that.
Do I need this line of code as well, "ErrorDocument 404 /mywebsite.com/error/404.php" line?
404 error page whether it is php or html both needs the .htaccess code. and yes it needs to be put inside your websites directory's .htaccess.
Code: Select all
RewriteEngine on
ErrorDocument 404 http://www.yoursite.com/404.php
or in some cases
Code: Select all
RewriteEngine on
ErrorDocument 404 /errors/404.php
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 7:09 am
by kreemerz
Hmmm... so in Cpanel, I need to add that code to add to the Error 404 page here right?
https://privatebin.support-tools.com/?7 ... GqXMDQdYI=
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 8:08 am
by WWBman
Your error page is
http://www.kreemerz.com/error/404.html
So the entry in the .htaccess file should be:
ErrorDocument 404 /error/404.html
Just one thing:
See my first reply regarding CSS style sheets.
If this rule still applies then this may be why things are jumbled up.
EDIT:
I've just tested it and the rule still applies.
I.E. The page must not have any external css style sheets so the option Tools > Option > HTML > CSS must be unticked
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 2:39 pm
by kreemerz
WWBman wrote: ↑Sun Apr 24, 2022 8:08 am
Your error page is
http://www.kreemerz.com/error/404.html
So the entry in the .htaccess file should be:
ErrorDocument 404 /error/404.html
Just one thing:
See my first reply regarding CSS style sheets.
If this rule still applies then this may be why things are jumbled up.
EDIT:
I've just tested it and the rule still applies.
I.E. The page must not have any external css style sheets so the option Tools > Option > HTML > CSS must be unticked
But isn't CSS needed for the rest of the site? I'm sure it's already uploaded to the servers. Would I need to delete the CSS folders?
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 2:50 pm
by WWBman
You can still use CSS just the same but untick the option Tools > Options > HTML > CSS > Generate external CSS style sheets for page specific styles.
I create a separate project just for the error page in its own folder..
That way only the error page project has the option unticked and all other projects can have the option ticked.
That's how I do it anyway.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 5:07 pm
by kreemerz
WWBman wrote: ↑Sun Apr 24, 2022 2:50 pm
You can still use CSS just the same but untick the option Tools > Options > HTML > CSS > Generate external CSS style sheets for page specific styles.
I create a separate project just for the error page in its own folder..
That way only the error page project has the option unticked and all other projects can have the option ticked.
That's how I do it anyway.
1. So I created a seperate project in WebBuilder and built the 404 page, made the page a PHP one in the builder, unticked the CSS sections.. Uploaded it.
2. Went into cPanel, went to Error pages and pasted
ErrorDocument 404 /error/404.php into the page as seen below:
https://privatebin.support-tools.com/?1 ... B0jfE1qU=
3. Tested by going to klnexus.com/notapage and my custom page still wont show. I get the default 404. Not sure why this is such a pain. Seemed like it was so easier of a process before.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 5:13 pm
by WWBman
You don't put the ErrorDocument 404 /error/404.php there it needs to be in the .htaccess file.
So if you are creating and publishing your error page project in the /error folder then that's exactly how my setup is.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 6:09 pm
by wwonderfull
Use the html 404 error page instead would do less hassel for you I think. It's much easier to implement which is very basic.
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 7:41 pm
by kreemerz
wwonderfull wrote: ↑Sun Apr 24, 2022 6:09 pm
Use the html 404 error page instead would do less hassel for you I think. It's much easier to implement which is very basic.
Still paste the same html code into the .htaccess file?
Re: Custom 404 pages.. making them work...
Posted: Sun Apr 24, 2022 7:42 pm
by kreemerz
WWBman wrote: ↑Sun Apr 24, 2022 5:13 pm
You don't put the
ErrorDocument 404 /error/404.php there it needs to be in the
.htaccess file.
So if you are creating and publishing your error page project in the
/error folder then that's exactly how my setup is.
Okay. I might have done that. But I'll give it a try again.
Re: Custom 404 pages.. making them work...
Posted: Mon Apr 25, 2022 1:40 am
by kreemerz
I finally got it to work.
Thank you all for your patience with me... I really appreciate it. I'm still learning some of this stuff..
@baconfries
@wwonderfull
@WWBman
Looks like the issue was that I was using the errorpage section of cPanel (using Bluehost's KB) and not going directly to the htaccess file...
Re: Custom 404 pages.. making them work...
Posted: Mon May 23, 2022 4:49 pm
by kreemerz
WWBman wrote: ↑Sun Apr 24, 2022 2:50 pm
You can still use CSS just the same but untick the option Tools > Options > HTML > CSS > Generate external CSS style sheets for page specific styles.
I create a separate project just for the error page in its own folder..
That way only the error page project has the option unticked and all other projects can have the option ticked.
That's how I do it anyway.
While this method does work for me, I do get broken links (where images are missing) on those error pages. Not sure what's causing that. Maybe my occasional upload of updates... kinda a drag to have to keep opening up a new project and uploading the error pages from there.
@wwonderfull had suggested the 'html error page' way of doing this.. I'm now wondering if that may be less of a hassle.
Re: Custom 404 pages.. making them work...
Posted: Tue May 24, 2022 7:47 am
by wwonderfull
While this method does work for me, I do get broken links (where images are missing) on those error pages. Not sure what's causing that. Maybe my occasional upload of updates... kinda a drag to have to keep opening up a new project and uploading the error pages from there.
@wwonderfull had suggested the 'html error page' way of doing this.. I'm now wondering if that may be less of a hassle.
404 error page is very simple to know.
In reality I my self as a user rarely got 5 views of 404 error page in a hole year of website browsing. Because the website is removed or has technical problems or the page has been removed from websites host server and showing on google's search engine result for some days before termination. 404 error page was just for a simple indication for people to know that the server cannot find the requested resource. Some people use searches and all that depending on what kind of content they have if they have hundreds and thousands of page they can use searches on 404 error page to lead to another page. But as I said it was an indication for people to know that the server cannot find the requested resource.
So just to show that "page not found" line people made simplest of way to show it from html to php. its just a basic text in the corner saying page not found. But now in modern days people added visuals backgrounds animations and more advanced use of it. It really depends on you what you want people to do when people find your broken page. If you want you can redirect a 404 error page user back to home page or the new page you have created.
HTML or PHP the main purpose is to show people that the "server cannot find the requested resource". So that being known, now I think you can decide what you would like to do with an 404 error page. You can use it creatively or you can use it natively meaning classic.
Re: Custom 404 pages.. making them work...
Posted: Tue May 24, 2022 7:49 am
by zinc
wwonderfull wrote: ↑Sun Apr 24, 2022 6:44 am
I guess the issue I'm having is how to make it work.. how do I get it to show up when you access a nonexistent page.
With the code <?php http_response_code(404); include('/error/404.php'); // provide your own HTML for the error page die();?> , do I place this in the same file (error/404.php)? or does it go in the .htaccess file?
Do I need this line of code as well, "ErrorDocument 404 /mywebsite.com/error/404.php" line?
For the php code I can say our dear moderator @bacon can assist you with his grateful advice on that.
Do I need this line of code as well, "ErrorDocument 404 /mywebsite.com/error/404.php" line?
404 error page whether it is php or html both needs the .htaccess code. and yes it needs to be put inside your websites directory's .htaccess.
Code: Select all
RewriteEngine on
ErrorDocument 404 http://www.yoursite.com/404.php
or in some cases
Code: Select all
RewriteEngine on
ErrorDocument 404 /errors/404.php
Very useful. Thank you!