WordPress Global Redirect

is_page() supports array too, so you could do something like this. add_action( ‘template_redirect’, ‘wpse_76802_goodbye_redirect’ ); function wpse_76802_goodbye_redirect() { if ( !is_page( array( 16372, 16384 ))) { wp_redirect( esc_url_raw( home_url( ‘index.php?page_id=16372’ ), 301 ) ); exit; } }

Stop wordpress redirecting www to non-www

What do you have set in the WordPress admin under Settings -> General and then WordPress Address and Site Address? Make sure these are both using the www.example.com domain. If you want to use an htaccess rule, which will run before WordPress kicks in, there are plenty of answers on StakOverflow such as this one: … Read more

WordPress Redirecting HTTPS Requests to HTTP

I don’t think this question can be answered without identifying the problem, which explains the comments. The main challenge is finding the cause, not fixing it. So here are some different solutions, some which were already mentioned in comments: Disable caching and refresh the page. In chrome press F12, go to Network tab, and check … Read more

Redirect based on parameter in url

You can use wp_redirect with something like… add_action( ‘init’, ‘my_redirect’); function my_redirect() { if (get_query_var(‘lang’) == “de”) { wp_redirect( site_url(‘/de/’) ); exit; } }

Redirecting old post url to 404 in wordpress using htaccess

I think doing this within WordPress is probably the preferred approach, as mentioned in @Harrison’s answer, however, to answer your specific queries… RewriteEngine On Redirect 404 /article.html Aside: The RewriteEngine directive relates to mod_rewrite, however, Redirect is a mod_alias directive – so these two directives are unrelated. However, this should “work” with a default WordPress … Read more

Redirect a page id url but not the page slug

Try using the pre_handle_404 hook instead: add_filter( ‘pre_handle_404’, ‘wpse_383506’, 10, 2 ); function wpse_383506( $preempt, $wp_query ) { if ( ! empty( $_GET[‘page_id’] ) && ‘342’ === $_GET[‘page_id’] ) { // Throw a 404 error. $wp_query->set_404(); // And prevent redirect to the page permalink (pretty URL). remove_action( ‘template_redirect’, ‘redirect_canonical’ ); } return $preempt; // always … Read more