0

I have an old 2004 Dreamweaver website built on HTML. Tired of the analytics telling me I have a lot of 404s, I created a 404.htm page. How do I link the code in .htaccess to it so it will show up, instead of a page not found text? Here is the .htaccess code:

RewriteEngine On 

RewriteCond %{HTTPS} off 

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^chronologicalbiblestudies\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.chronologicalbiblestudies\.com$
RewriteRule ^/?$ "https\:\/\/www\.chronologicalbiblestudies\.com\/chronologicalbiblestudies\.htm" [R=301,L]
4
  • 1
    "Tired of the analytics telling me I have a lot of 404s" - But are these legitimate 404s or do they need "correcting", ie. caused by typos in requests or errors in internal links? 404s are a fact of managing a website - you cannot (or should not) simply make them "go away" if that is what you are implying.
    – MrWhite
    Commented Mar 7, 2022 at 17:31
  • When you say "link the code," are you saying that some of our code is showing a 404 when it should be showing content? Commented Mar 7, 2022 at 19:14
  • Mr. White, I don't mean to make them go away; I just want to help the visitor get to the right page if he typed in my site's address wrong or something went wrong with a link on my site. Commented Mar 8, 2022 at 14:58
  • Stephen Ostermiller, this is what comes back if I type blah on the end of my extension: Not Found The requested URL was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Commented Mar 8, 2022 at 15:00

1 Answer 1

1

You need to add the following code inside your .htaccess:

ErrorDocument 404 /404.htm

After that, you can test it by typing a non-existing page:

https://example.com/idontexist.html

Your custom 404 page should appear instead of just a page not found text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.