skip to Main Content

Is there anyway I can duplicate the homepage to be used as content for the woocommerce shop page. So basically just using the same page for two URL homepage and shoppage. Support told me to use redirect canonical URL if I want to avoid creating redirects.

So we can have multiple URLs lead to the same page, to prevent any SEO demerits for duplicate content as long as the link rel=”canonical” is enabled. I tried using the below code in Wordrpress in functions.php but it won’t work. The URLs are https://lullyandrose.com.au/shop and I want to use the content of the Homepage which is https://lullyandrose.com.au/

add_filter( 'redirect_canonical', 'custom_redirect_canonical', 10, 2 );
function custom_redirect_canonical( $redirect_url, $requested_url ) {
    if( $requested_url == 'https://lullyandrose.com.au/shop' ) {
        return $redirect_url == '/';
    }   
}

2

Answers


  1. Need no to redirect it, just follow the below given steps and you are done…

    1. Login as a administrator and go to Settings >> Reading
    2. At the Your homepage displays section, check out A static page (select below)
    3. In the Homepage dropdrown, select your SHOP page and save the changes, you are done

    see below given screenshot
    enter image description here

    Login or Signup to reply.
  2. must be help if you want show home page if request page shop page

    add_filter( 'redirect_canonical', 'custom_redirect_canonical', 10, 2 );
    function custom_redirect_canonical( $redirect_url, $requested_url ) {
      if($redirect_url == is_shop()){
            return $redirect_url == '/';
            
            // and you can use this 
            // wp_redirect(site_url());
            // exit;
        }   
    }
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search