Remove archives in your WordPress website

Sometime some people need to remove Archives from their WordPress web site. This snippet is actually doing permanent redirect 301 to home page. Well, the result is that archive is no more available. As usually, place this code snippet to your function.php file.

//remove archives
function redirect_to_home($query)
{if (is_date())
{wp_redirect(home_url(), $status = 301);exit;}}
add_action('parse_query', 'redirect_to_home');