• Resolved deyil

    (@deyil)


    I want to setup a redirection when there is a ?lang=el parameter in URL, to trip it and redirect to /el. Examples:

    FROM: domain.com/?lang=el
    TO: domain.com/el

    FROM: domain.com/shop/?lang=el&sale_products=on
    TO: domain.com/el/shop/?sale_products=on

    Can this be achieved with the plugin? And how?

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author John Godley

    (@johnny5)

    Sure, it’s not different from any other URL.

    If you need to match multiple URLs then you can use a regular expression:

    https://redirection.me/support/redirect-regular-expressions/

    Thread Starter deyil

    (@deyil)

    @johnny5 thank you for your answer and your excellent plugin.

    I understand that this can be achieved by regex but since this is a more complicated regex, I am not experienced with it.

    Because it is a common scenario Language redirection (I have found several solutions with htaccess), I asked to see if someone has already implemented this with your plugin to show me how.

    I tried importing htaccess but it didn’t work 🙁

    Plugin Author John Godley

    (@johnny5)

    Regular expressions are not specific to Redirection. I understand that they are a complicated subject, but there is a lot of information about them on the internet, and so I can only suggest you look through other examples, and use something like https://regex101.com/, to achieve the result you want.

    Maybe if you post what you’ve tried then it might be easier to give suggestions.

    Thread Starter deyil

    (@deyil)

    After some trials and errors, I came with the following rule. I know it is not perfect, but I hope it helps others. Also, any suggestions for improvements are welcomed.

    SOURCE
    /(.*)lang=([a-z]{2})(&?)

    TARGET
    https://domain.com/$2/$1

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redirect for ?lang parameter’ is closed to new replies.