简体   繁体   English

我的子域路由覆盖了 laravel 7 中的正常网络路由

[英]My subdomain routes are overwriting my normal web routes in laravel 7

Hello devs I have a project of laravel 7 in which I am trying to use sub-domain routes and I am able to do that but after adding subdomain routes I am facing an issue in which it is prefixing the subdomain in all the routes开发人员您好,我有一个 laravel 7 项目,我在其中尝试使用子域路由,我可以这样做,但是在添加子域路由后,我面临一个问题,即它在所有路由中为子域添加前缀

This is the subdomain route这是子域路由


Route::domain('demo.'.config('app.domain'))->group(function () {
    Route::name('demo.')->group(function () {
        Route::get('/', 'DemoController@index')->name('index');
    });
});

This is the main route (web.php)这是主要路线(web.php)


Route::group([], function() {
    Route::get('/', 'FrontController@index')->name('index');
    Route::get('/about-us', 'FrontController@about')->name('about-us');
    Route::get('/contact-us', 'FrontController@contact')->name('contact-us');
    // More routes.....
});

But when I am calling the main (web.php) routes it is applying the subdomain as the main domain但是当我调用主(web.php)路由时,它将子域作为主域

Example例子

<a href="{{ currentRouteIs('index') ? '#hero' : route('index') }}">Home</a>
<a href="{{ route('about-us') }}">About Us</a>
<a href="{{ route('contact-us') }}">Contact Us</a>

It needs to show the domain.com , domain.com/about-us and domain.com/contact-us but it is showing like this demo.domain.com , demo.domain.com/about-us and so on它需要显示domain.comdomain.com/about-usdomain.com/contact-us但它显示像这样demo.domain.comdemo.domain.com/about-us等等

I don't know what is the solution please help me with this.我不知道什么是解决方案,请帮我解决这个问题。

Thank you in advance.先感谢您。

Your index routes have the same name.您的索引路由具有相同的名称。 Try altering the route name on the subdomain:尝试更改子域上的路由名称:

Route::domain('demo.'.config('app.domain'))->group(function () {
    Route::name('demo.')->group(function () {
        Route::get('/', 'DemoController@index')->name('demo.index');
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM