0

I need to 301 redirect in WooCommerce :

http://www.sitename/shop/product-category/sample-product/product-name

to

http://www.sitename/product/product-name

  • I think it's better to write with htaccess – p_rahimizade Sep 26 '17 at 18:30
0

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.

  • I think it's better to write with htaccess – p_rahimizade Sep 26 '17 at 18:30
  • 1
    Wordpress has a special function for redirect - wp_redirect(). Why do you think .htaccess is better? – Mikhail Malyi Sep 26 '17 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.