How do I redirect the browser to 404 page, if no posts are found in home page

Well, detecting a 404 from .htaccess isn’t possible. This is because the .htaccess file is going to route any requests for non-existing pages to the index.php file. From there, WordPress will do a lookup in the database to see if the current request matches any content in the database.

If not, then WordPress returns a 404. Handling requests for non-existing pages in .htaccess would mean that WordPress would never load. As such, you’d have to handle the redirection login within WordPress itself.

I’d recommend the following plugin: https://wordpress.org/plugins/all-404-redirect-to-homepage/ (you can redirect to a specific page, not just the homepage).

or you can add this code but is not really going to work:

ErrorDocument 404 http://www.example.com/error.html

Instead, try this php code in functions.php

add_action( 'wp', 'se344018_redirect_404' );
function se344018_redirect_404()
{
    if ( is_404() ) {
        wp_redirect( home_url() );
        //
        // wp_redirect( home_url('some/page-slug') );
        exit;
    }
}

I found the code in https://ananchor.com 👍

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)