4 years ago

Route to redirect but keep other variables

Posted 4 years ago by raphadko

Hey guys, I'm a bit new to laravel and I want to accomplish something I don know if possible..

I have a couple translation routes:

mydomain.com/pt -> sets cookie to portuguese language and redirects user to home (cookie will be checked in middleware and language will be set)

I want something that, from any page on my website, if the user gets the /pt in the url, the same would happen, but the url will be kept...

For example:

If the user visits mydomain.com/welcome - they will se a welcome page if they visit mydomain.com/pt/welcome - the '/pt' route will set the language and then redirect to welcome.. If they visit mydomain.com/pt/profile - the '/pt/ will do the same...

So basically, instead of just enabling /pt and redirect for the home screen, I want all the pages to have this option.

How could I accomplish this?

Please sign in or create an account to participate in this conversation.