Familie Goldenbelt
Familie Goldenbelt

Reputation: 11

How to redirect a dynamic link?

I moved my complete laravel directory to a subfolder website.com/folder, but normally people sign up with an affiliate link at website.com/register/affiliate, where affiliate is dynamic.

Is it possible to create a redirect towards the same dynamic link in a different folder?

So for example:

When user goes to website.com/register/affiliate1 it goes to website.com/folder/register/affiliate1

Affiliate1 has to be dynamic, can be every user in the database.

Thank you in advance.

Upvotes: 1

Views: 246

Answers (1)

mrhn
mrhn

Reputation: 18916

Either I'm misunderstanding the problem or else this is pretty straight forward. Laravel routes can parse dynamic url parameters.

Route::get('/register/{var}', function ($var) {
    return redirect('folder/register/' . $var);
});

You can also do it in Apache or Nginx, but if you want to keep it in Laravel. This is the approach.

Upvotes: 1

Related Questions