Is there a function that can be created or a line of php code that can be used to maintain a page URL ending? An example of what I mean is lets say a english and french toggle. If my URL is http://sitename.com/en/cars if a user clicks the french toggle I would like the URL to refresh to http://sitename.com/fr/cars. This link is found in the header so it needs to output the same page ending each time.
I recall seeing something similar to this idea but I cannot remember the name or what it falls under.