Contributors should only access home page

Yes this is possible. You can use the login_redirect filter to do this.

Use the code below in your active theme’s functions.php file.

function my_login_redirect( $redirect_to, $request, $user ) {
    //is there a user to check?
    global $user;
    if( isset( $user->roles ) && is_array( $user->roles ) ) {
        //check for contributors
        if( in_array( "contributor", $user->roles ) ) {
            // redirect them to the home page $home_url should contain the home page url
            return $home_url;
        } else {
            return $redirect_to;
        }
    } else {
        return $redirect_to;
    }
}
add_filter("login_redirect", "my_login_redirect", 10, 3);