Redirect based on parameter in url

I want to redirect my site to the correct url based on parameter. The url is passed when changing the language of the si

I want to redirect my site to the correct url based on parameter. The url is passed when changing the language of the site using the language switcher.

If url contains lang=de, then redirect to example/de/ If url contains lang=es, then redirect to example/es/

I've tried using the Redirection plugin by John Godley but I'm not sure how to set it up.

What's the best way to get this done?

I want to redirect my site to the correct url based on parameter. The url is passed when changing the language of the site using the language switcher.

If url contains lang=de, then redirect to example/de/ If url contains lang=es, then redirect to example/es/

I've tried using the Redirection plugin by John Godley but I'm not sure how to set it up.

What's the best way to get this done?

Share Improve this question asked Jan 27, 2020 at 11:45 Marco VMarco V 1131 silver badge6 bronze badges 2
  • Which plugin you have used – Ankush Kumar Commented Jan 27, 2020 at 11:49
  • Redirection plugin by John Godley – Marco V Commented Jan 27, 2020 at 11:53
Add a comment  | 

1 Answer 1

Reset to default 3

You can use wp_redirect with something like...

add_action( 'init', 'my_redirect');
function my_redirect() {
    if (get_query_var('lang') == "de") {
        wp_redirect( site_url('/de/') ); 
        exit; 
    }   
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744800880a4594481.html

相关推荐

  • Redirect based on parameter in url

    I want to redirect my site to the correct url based on parameter. The url is passed when changing the language of the si

    2天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信