【发布时间】:2021-10-03 09:49:47
【问题描述】:
我在 routes 文件夹中有三个路由文件:
- web.php
- api.php
- admin.php
我在RouteServiceProvider的boot()方法中注册了文件admin.php,如下:
public function boot() {
$this->configureRateLimiting();
$this->routes(function () {
Route::domain("admin." . env("APP_URL"))
->namespace($this->namespace)
->group(base_path("routes/admin.php"));
Route::domain("api." . env("APP_URL"))
->middleware("api")
->namespace($this->namespace)
->group(base_path("routes/api.php"));
Route::middleware("web")
->namespace($this->namespace)
->group(base_path("routes/web.php"));
});
}
假设我在 web.php 中定义了以下路由:
Route::get("test", function() {
return "Hello from website route";
});
如果我尝试使用 mywebsite.com/test 访问此路由,它会像预期的那样运行。
但是,如果我尝试访问链接 admin.mywebsite.com/test 它仍然会返回到 mywebsite.com/test 并给出确切的相同的输出。
这里有什么问题?
【问题讨论】: