在Laravel 9中添加子域
由于某种原因,添加子域路由不起作用,并且不断返回我的主页而不是我需要的页面。我在应用程序中使用了Laravel,interiajs vue。
这是我的路线:
Route::domain('webshopview.localhost:8000')->group(function () {
Route::get('/webshopview', function () {
return Inertia::render('Products/Index');
});
});
我希望能够以WebShopview.localhost:8000访问它,但是每次我尝试访问此路线时,都会返回我的应用主页。如果我像以下示例那样在普通路线上这样做,它就像魅力一样。
Route::get('/webshopview', function () {
return Inertia::render('Products/Index');
});
为一组路线创建子域的缺少是什么?为什么它不断返回应用主页忽略子域
我的应用程序在'http:// localhost:8000/'和'http://127.0.0.1.1:8000/'上本地工作,并且默认情况下它可以像我这样做任何事情。因此,我想要的只是将子域添加到特定路由上,以便我可以像这个'example.localhost:8000'或'example.127.0.0.1:8000'这样访问。最终结果是在部署'https://www.subdomain.domain.com'
我什至尝试过时,将其显示为这样的路线:
Route::get('/productview', function () {
return 'First sub domain';
})->domain('productview.localhost');
现在访问'http://productview.localhost/'返回“无法达到此站点”错误。
For some reason adding subdomain route isn't working and keeps on returning my homepage instead of the page I need. I'm using Laravel, Inertiajs Vue in my app.
Here is my route:
Route::domain('webshopview.localhost:8000')->group(function () {
Route::get('/webshopview', function () {
return Inertia::render('Products/Index');
});
});
I want to be able to access it as webshopview.localhost:8000 but every time I try to visit this route it returns my app home page. If I do this in normal route like the below example, it works like a charm.
Route::get('/webshopview', function () {
return Inertia::render('Products/Index');
});
What is missing to create a subdomain for group of routes? Why it keeps returning the app homepage ignoring the subdomain
My app works locally on 'http://localhost:8000/' and 'http://127.0.0.1:8000/' and it works like that by default without me doing anything. So all I want is to add subdomain to specific routes so that I can access like this 'example.localhost:8000' or 'example.127.0.0.1:8000'. The end result is to have the route displayed like this after deployment 'https://www.subdomain.domain.com'
I even tried this and it didn't work:
Route::get('/productview', function () {
return 'First sub domain';
})->domain('productview.localhost');
now accessing 'http://productview.localhost/' returns 'This site can’t be reached' error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我必须手动在Windows上的etc/hosts文件中添加路由,然后重新启动整个计算机才能生效。
I had to manually add the routes in my etc/hosts file on windows and restart the entire machine for it to take effect.