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.
Asked
Active
Viewed 2,754 times
3 Answers
2
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.

gtanaselea
- 21
- 3
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;
}

Kishan Kothari
- 21
- 4
1
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

Eqab Almutairi
- 11
- 3
-
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Albert Logic Einstein Sep 14 '22 at 16:42