Answer the question
In order to leave comments, you need to log in
Laravel wildcard subdomain not working?
I found out about the wildcard subdomain, having done everything according to the manual, the domain still does not hail.
Added an entry to the DNS server
Name Record type and IP
*.test.ru A 1.1.1.1
web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ShopController;
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::domain('{domain}.test.ru')->group(function () {
Route::get('/', [ShopController::class, 'index']);
});
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
class ShopController extends Controller
{
public function index($domain)
{
$user = User::where('domain', $domain)->first();
if(!$user){
return true;
}else{
return false;
}
}
}
Answer the question
In order to leave comments, you need to log in
In alias in apache config, specified *.test.ru
PS test.ru is an example, i.e. main domain hid
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question