没有URI的子域基础,无法捕获基础URL [英] Subdomain Base Without URI , Unable to catch base url
问题描述
Route::domain('{account}.myapp.com')->group(function () {
Route::get('/', function ($account) {
dd("Cant hit this area");
});
Route::get('/test', function ($account) {
dd("No problem reaching this area");
});
});
当我访问自己的子域时,例如test.myapp.com它不会达到该DD,但是如果说我做一个/test并访问它,它将起作用.
When I visit my subdomain e.g. test.myapp.com it won't hit that DD but if say I do a /test and visit it, it would work.
我也尝试过Route :: get('',将其保留为空,但不会捕获基本子域.
I tried doing Route::get(' ' too , leaving it empty but it just wouldn't catch the base subdomain.
我的Apache Conf:ServerAlias *.example.com
My Apache Conf : ServerAlias *.example.com
Ref: https://laravel.com/docs /5.8/routing#route-group-sub-domain-routing
更新
我也尝试过,无法执行
Route::group(['domain' => '{account}.example.co'], function () {
Route::get('/', function ($account) {
dd("HIT");
});
});
推荐答案
找到了解决方案.
基本上,我在发布的代码上方拥有这个
Basically, I had this above the code I posted
Route::get('/', ['uses' => 'MainController@home']);
它正在覆盖我当前的路线.我将代码移到该代码上方,以免被它覆盖.
It was overwriting my current route. I shifted my code above this code so it doesn't get overwritten by it.
这篇关于没有URI的子域基础,无法捕获基础URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!