-1

If I click on the blog button than generate blog.test.local and click on the home button than generate test.local so how can I check domain URL an sub-domain URL.

    Route::domain('{account}.test.local')->middleware('mymiddle')->group(function () {
        Route::any('/', 'Blog\BlogController@index')->name('blog');
    });

if sub-domain blog exits than call blog.test.local. and if I click on the home then call test.local normal url.

How can I check ? I create middleware but it didn't solve the problem :

public function handle($request, Closure $next)
{
    URL::defaults(['account' => request('account')]);
    return $next($request);
}
iizno
  • 829
  • 1
  • 9
  • 28

1 Answers1

0

Request are making from your front-end.So, if you gave a user route that has a 'sub-domain' url, there is no need to check whether it is sub-domain or not in your route.

Now if your user click a sub-domain,you redirect them on the basis of something; suppose

Route::any('/', 'Blog\BlogController@home')->name('home');
Route::any('/blog', 'Blog\BlogController@index')->name('blog');

Route::domain('{account}.test.local')->group(function () {
        if(Route::has('blog')){
           return redirect->route('blog');
        }else
        {
           return redirect->route('home');
        }
    });
Md. Amirozzaman
  • 1,083
  • 10
  • 21