Reputation: 39
How can I show for example this route "example.com/parameter" to this "parameter.example.com" for site visitors . the back-end of site is laravel 5.3 and web server is Apache. I want to use parameter in laravel controller.
Upvotes: 0
Views: 903
Reputation: 441
You can set up a subdomain route like this:
Route::group(['domain' => '{parameter}.example.com'], function () {
Route::get('/', 'UserController@showByParameter');
});
then in your controller you can do
public function showByParameter($parameter)
{
$user = \App\User::whereParameter($parameter)->firstOrFail();
return view('users.show', compact('user'));
}
Upvotes: 1