2

In my laravel project app, I have the following routes. app.client.net for user registration and wildcard subdomain *.client.net for logged in users. Route.php

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::group(['domain' => 'app.client.net'], function(){
    Route::get('/', function () {
        if (auth()->check()) {
            return redirect('http://'.session('subdomain').'.client.net/home');
        }       
        return view('welcome');
    })->name('homepage');   
    Route::get('/register', 'Auth\RegisterController@showRegistrationForm')->name('register');
    Route::post('/register', 'Auth\RegisterController@register');
    Route::get('/login', 'Auth\LoginController@showLoginForm')->name('login');
    Route::post('/login', 'Auth\LoginController@login')->name('login');
    Route::get('/setupCompany', 'CompanyController@setupCompanyForm')->name('setupCompanyForm');
    Route::post('/setupCompany', 'CompanyController@setupCompany')->name('setupCompany');
    Route::get('/register/verify', 'CompanyController@verfiy')->name('registerVerify');

});

Route::group(['domain'=> '{subdomain}.client.net', 'middleware' => 'checkSubdomain'],function () {
    Route::get('/', 'Auth\CompanyLoginController@showLoginForm')->name('companyLogin');
    Route::post('/', 'Auth\CompanyLoginController@login')->name('companyLogin');

    Route::group(['middleware' => 'customAuth'],function(){         
        Route::get('/home', 'HomeController@index')->name('home');
        Route::post('/logout', 'Auth\LoginController@logout')->name('logout');
        Route::post('/inviteClient', 'HomeController@inviteClient'); //ajax req
        Route::get('/profile', ['as' => 'profile.edit', 'uses' => 'ProfileController@edit']);
        Route::put('profile', ['as' => 'profile.update', 'uses' => 'ProfileController@update']);
        Route::put('profile/password', ['as' => 'profile.password', 'uses' => 'ProfileController@password']);

        Route::get('/getClients', 'HomeController@clients'); //ajax req

    });
});


this is working good on localhost but when I deployed it on a live server by making app.client.net subdomain on server and deployed project there then wildcard subdomain {subdomain}.client.net is not working. when I go to app.client.net it is working properly but when I go to wildcard subdomain e.g abc.client.net it gives following error.

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

how to configure this so that static subdomain and wildcard subdomain can work on server subdomain. Or I have to make two subdomains on server app.client.net and *.client.net separately, one is for static subdomain and other one is for wildcard subdomain and deploys static subdomain routes on app.client.net server subdomain and wildcard subdomain routes on *.client.net server wildcard subdomain separately? Thanks in advance.

habib
  • 89
  • 1
  • 10

0 Answers0