• Resolved anotherbreed

    (@anotherbreed)


    Hi there,

    I have set that my Shop Page is also my Front Page. I previously had two separate pages for each one and decided to delete the page I used as Front Page.

    The problem is that the page that is now designed to be the Front Page (which is now accessible as https://www.mysite.com) can still be visited using the previous slug / permalink (which was https://www.mysite.com/shop-page), and it takes the visitor to the same content. So I have two URLs for the same page.

    I don’t think that is good for SEO, do you have any advice? Is it safe to use a redirect 301 on my htaccess for this issue?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Mohit Mishra

    (@mohitmishra)

    Hello @anotherbreed , You can get your goal by using the below code and when anyone tries to open the shop page. Then it will redirect him to the home page on your site. You have just pasted this code functions.php file of the current activated file.
    Regards
    Mohit Mishra(WooCommerce developer at MakeWebBetter)

    /**
    * Function is used for the redirect shop page to the homepage.
    * 
    * @name custom_template_redirect
    * @author Mohit Mishra MakeWebBetter
    * @link https://makewebbetter.com
    * @since 1.0.0
    */
    function custom_template_redirect() {
        if( is_shop() ) ://check is shop page.
        	wp_redirect(home_url());//Redirect to the homepage.
            exit();
        endif;    
    }
    add_action( 'template_redirect', 'custom_template_redirect' );
    Thread Starter anotherbreed

    (@anotherbreed)

    Hi Mohit,

    thanks for replying.

    Since you used is_shop(), I carefully tested your code using echo "Hello world!"; and turns out that it was displayed on both URLs. Both of them take to the Shop, and a redirect loop would occur using that function.

    Many thanks

    Mohit Mishra

    (@mohitmishra)

    @anotherbreed Do one thing. Whatever page you have designed for the front page go to the edit page of that page. Then go the page attribute settings and select the homepage there. Then I think all the problems will get resolved.Here is the screenshot of that.https://imgur.com/z8jnZckl.png

    Thread Starter anotherbreed

    (@anotherbreed)

    Hi Mohit,

    no luck with that, but from your suggestion I was able to investigate further on the page and its permalink – turns out I was able to fix the problem by removing the page completely and create a new one (with the same content) from scratch.

    I have an active plugin that automatically creates redirects when permalinks change, and it probably was responsible for creating two different URLs for the same page. Also to note that I was using the URL to the old Shop Page on the menu, that could be another cause.

    Now everything works as it should ??

    Thanks for the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Front Page and Shop Page set to be the same, but Shop Page still has a Permalink’ is closed to new replies.