I deleted the 404 page and the errors folder etc. and started over. I created a 404.html page as you said at the root, and set the permissions to 755. This is what I put at the end of the .htaccess file:
RewriteEngine on
ErrorDocument 404 /404.html
If I go to the website, and enter an invalid address at the end of the URL, the 404 page seems to be working OK. So I’m really happy to have that part of this finally working! The problem I am still having, is recently I rebuilt and republished this website and omitted a lot of old pages that were getting obsolete. When I go to Google and search the site, it still shows many of those obsolete pages. If I click on one, the new 404 page shows up, but the image doesn’t show and it looks like it has no formatting. I’ll try to include an example link here. Google link. I’ve done some 301 redirects, but there are too many old pages to do them all. Do you know what might be causing this to look OK from the site directly, but not from a search? I think that’s where the 404 would be the most useful, so I’d really like to get it working there somehow. Sorry this is so long!
I like your Pizza 404 page, it’s cute. I’m glad it’s working for you! Mine is finally working, but only by typing in a wrong URL at the site, and not from a link of an obsolete page at Google. I put what I did last in a post below. I’m about ready to throw in the towel, but I sincerely thank you for all the time and effort you have given to this to help me!
When I click on your home or contact buttons in Nav i get taken to the 404 page, as well as if i enter http:/kentwoodshavings.co.uk or click on the site title. In order to view your home page i have to enter http:/kentwoodshavings.co.uk/index.html Just wondering if that’s the behavior you intended.
@cythhia, read my post above.
Step 1. Try putting the full url to the 404 page in the .htaccess, see if that clears things up.
If that works then at the bottom of your .htaccess put the full set of steps in from the post above origionally from doobox.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /404.html [L,R=301]
I did that last night, and I tried it again now. When I add the three lines at the bottom of the .htaccess file, the links stop working on the site, and so did the search box. When you click a link in the menu bar, or even most of the text links, or did a search, they all lead back to the 404 page, so I had to remove that from the .htacccess file. Currently I still just have:
RewriteEngine on
ErrorDocument 404 /404.html
on the bottom, but it still doesn’t work correctly, but thanks!
my error doc is: /public_html/404.html (/public_html) is my doc_root
Originally I only had ./404.html as the path in my .htaccess file and I was getting the same behavior you are experiencing. Once I put the full path in (case counts on my server) it worked from anywhere.
Thanks for pointing this out - much appreciated. Shows how you should take time over these things - I was only interested in the redirect from a non-existent pages and sub-pages - not thorough enough. Fortunately it’s my smallest and least used site - which is why I tested on it. deleted htaccess for now and will take another look. Thanks again!
No problem - glad it was helpful. I’ve been following the thread and I’ve become a little apprehensive to jump in a give the custom 404 from RW a try. I’ll be interested to know what you come up with. Good Luck!
I think you fixed it!!! Yes, I believe I’m on an Apache server, and I’m almost afraid to tell you. I think I had it entered wrong when I put in the full URL. When I saw your example, it wasn’t the same as mine. I think I left in a / after ErrorDocument 404 before I entered the full URL. I guess I didn’t know exactly how to enter it correctly. I’m so sorry! I’m hoping that it is working now, not only from the different levels of the site, but rendering correctly from a search engine too. When I tried to check it a few different ways, it seems to me like it’s working now. Thank You, Thank You, so much!! This has been a nightmare for me, just trying to get this working. Thank You all for working so hard on this and for trying to help me so much! I truly appreciate you!!
AT LAST - works perfectly and sooooo simple! I’m sure we’re all grateful to see a happy end to this thread - google the problem and you’ll see there’s a lot of confusion. Thanks to all for your persistence and @swilliam for the simple solution
If anyone doesn’t want to plough through all of this thread and needs to add a custom 404 that works for top level URL errors and sub-directories - here’s a summary for dummies (like me).
Create your custom 404 error page just like any other page in RW
De-select “show in navigation”
Call the page something relevant - “404” is probably easiest but up to you. I use “notfound”
Leave it in root folder (/)
Using FTP, add an .htaccess file at root level on your server or modify if already there. Add the following to it:
If there are problems with this it is possible your hosting service does not allow user-modified .htaccess files. In which case, see if there are error pages you can edit in cPanel insteasd, or ask your hosting service to help - or change hosting service.
And that should be it. However, I’ve been drinking tonight so test it first…and if I’ve summarised incorrectly shoot me down in flames.