I know how to do this using php, but need to redirect using htaccess.
If I use this rule: ErrorDocument 404 /index.php then I still get the error page. Looks like wordpress identifies that this is 404 error and serves 404 message, not the homepage content as needed.
Any ideas?
I know how to do this using php, but need to redirect using htaccess.
If I use this rule: ErrorDocument 404 /index.php then I still get the error page. Looks like wordpress identifies that this is 404 error and serves 404 message, not the homepage content as needed.
Any ideas?
There are a couple of ways to do this.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit();
?>
<?php
function redirect_404s() {
if(is_404()) {
wp_redirect(home_url(), '301');
}
}
add_action('wp_enqueue_scripts', 'redirect_404s');
?>