Takeshi Tokugawa YD
Takeshi Tokugawa YD

Reputation: 961

Laravel: redirect to constructed url

E.G. we want to redirect to

http://example.loc/common/{$alias}

Suppose that http://example.loc/common/ route has a pseudo name - common. All that remain is build the Redirect::route expression; it would be something like

Redirect::url('common/{$alias}'); // warning: invalid code

Upvotes: 1

Views: 251

Answers (2)

Lloople
Lloople

Reputation: 1824

You can redirect to a url writing it as a string

$alias = 'some-url';
redirect('common/'.$alias);

Also, if you know the route and it's a named route, you can use

redirect()->route('named.route', $alias);

Upvotes: 0

user7325973
user7325973

Reputation: 182

You can have any of below methods i guess.

$data = '1234';
return redirect('common/'.$abc);

or

$url = 'commom/'.$data;
return Redirect::to($url);

Upvotes: 1

Related Questions