2017-09-20 183 views
1

我在Laravel非常新。我目前在Laravel 5.5上创建了我的个人网站,并上传到GoDaddy服务器:http://bhattraideb.com/。现在,当我点击“博客”从导航我想重定向像http://blog.bhattraideb.com/这是目前重定向到'bhattraideb.com/public/blog'。Laravel 5.5路由和子域路由

从同此链接“ bhattraideb.com/public/blog”当我在“恢复”我的方面点击在“ bhattraideb.com/

这里是我的路线代码重定向

再次

// **恢复路由

Route::prefix('/')->group(function() { 
    Route::get('/', 'Frontend\[email protected]')->name('resume.index'); 
    Route::resource('resume', 'Frontend\ResumeController'); 
}); 

// **博客路线

Route::get('show/{id}', 'Frontend\[email protected]')->name('post.show'); 
Route::get('blog/{slug}', ['as' => 'post.single', 'uses' => 'Frontend\[email protected]'])->where('slug', '[\w\d-\_]+'); 
Route::resource('blog', 'Frontend\PostController'); 

任何人都可以请指导我这一点。

在此先感谢。

回答

0

您可以https://laravel.com/docs/5.5/routing#route-group-sub-domain-routing读了这方面的更多细节,但下面简单的例子应该工作:

web.php

Route::group(["domain" => "blog.bhattraideb.com" ], function() { 
    Route::get("/", "Frontend\PostController")->name("blog.index"); 
    //All blog routes should be defined in here 
}); 

然后,您可以使用助手route("blog.index")来获取URL以及生成链接到博客时的子域。

请注意,您需要将网络服务器设置为接受blog.bhattraideb.com作为bhattraideb.com的别名。然后Laravel将其余的排序出来

+0

谢谢@apokryfos。它工作正常。 – bhattraideb