skip to Main Content

I am using polylang plugin for wordpress multi language site.
As per SEO guidelines, home page www.myweb.com should redirect to www.myweb.com/en with 301 status. Currently its redirecting with 302 status.
function home_requested() does this but we can’t touch the plugin core functions.
I tried by adding filter for this function. Also tried by add filter for wp_redirect function but not working.
Is there any other way to sort this. Thank you.

3

Answers


  1. You probably fixed this already, however, posting for other people that are looking to solve this issue.

    I solved it by editing the choose-lang.php file in the plugin

    wp-content->plugins->polylang->frontend->choose-lang.php :277 or do a ctrl + f for 302 and replace that with 301.

    Login or Signup to reply.
  2. I tested below code working fine.

    Add below code in functions.php file

    add_filter('pll_redirect_home', 'my_pll_redirect_home' );
    function my_pll_redirect_home( $redirect ) 
    {
        header( 'Vary: Accept-Language' );
        wp_safe_redirect( $redirect, 301, POLYLANG );
        exit;
    }
    
    Login or Signup to reply.
  3. i tested functions.php not work for me.

    nano /polylang/frontend/choose-lang.php (line +265)

    change 302 to 301. you done.

    and it will reset itself after any polylang update

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search