set up a 301 redirect htaccess wordpress code example
Example 1: redirect 301 wordpress
add_action( 'template_redirect', 'redirect_to_other_page' );
function redirect_to_other_page() {
if ( is_page( 143 ) ) {
wp_redirect( '"'.home_url().'/services/messenger/"', 301 );
///wp_redirect( 'example.com/page', 301 );
exit;
}
}
Example 2: redirect htaccess 301
Redirect 301 /pagename.php http://www.domain.com/pagename.html