Jump to content

preservation of GET params during language redirects


Recommended Posts

I want to guide users from an external system to a page, passing a GET parameter and specifying the target language. We're using localized URLs, so the idea is that the external system knows only about the default language URL and prepends the language if different to default (German), making the user land on the page in the given language together with the GET parameter.

As an exapmle, a German speaking user would land directly on: /meineseite/?param=value
An English user will land first on /en/meineseite/?param=value, which should then get redirected to the localized URL /en/mysite/?param=value.

Unfortunately the GET param gets lost during the process of redirecting. I already tried without success to hook into Session::redirect to conserve GET params.
As a possible solution I see creating a page, which takes an ID of the page it should redirect to, handling the resolution of the URL according to the language while conserving the GET params. However, I see this as a  not too nice workaround to my current problem.

Do you have any suggestions on how I could solve my problem?

Link to comment
Share on other sites

  • 3 months later...

Hi,

sorry to be so late to see your question... but, just in case it can still help

this is something you could solve with htaccess rules but get params are nearby devs security nightmares because visible and a black hat temptation
instead of params, you may use pw url segments, allowing them for the relevant templates, they act like get params but in a far more discreet and configurable way 🙂

have a nice day

Link to comment
Share on other sites

On page /en/meineseite/?param=value first save the param into a session var, then do the redirect and in the target page read out the session var

$value = $input->get('param');
$value = $sanitizer->text($value); // or any other appropriate sanitizer method for your usecase, and or any other custom validation
$session->set('param', "$value");

$session->redirect($YOUR_TARGET_URL);

$value = $session->get('param');

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...