how to write 301 redirect code for woocommerce product

If you already created a new product you can write directly in your product template before get_header() global $post; if($post->ID===$your_old_product_ID){ wp_redirect(site_url(‘/product/product-name/’),301); } But it will be better if you create some custom field in products to manage their redirects.

Redirect User to Specific Page

As this is A WordPress Specific: function my_page_template_redirect_cookie() { if( is_front_page() && isset($_COOKIE[‘the_cookie’]) ){ wp_redirect( home_url( ‘/folder1/’ ) ); die; } } add_action( ‘template_redirect’, ‘my_page_template_redirect_cookie’ );

How do I skip wordpress’s 404 handling?

Native WordPress rules are designed to ignore any existing files and directories, including arbitrary PHP scripts. This is literally what this part of directives mean: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d So under normal circumstances WP just shouldn’t be involved with your request in any way. You may have some other rewrite rules interfering, possibly … Read more

All new posts serving 301 redirect

Out of curiosity, does the Post Preview page redirect as well? If it don’t redirect, then it sounds like a cache problem. If it does redirect, there are more things to try. NB: First back-up your site (always a good idea before debugging anything.) As you may not know what the developer edited, back up … Read more