重定向 就是从一个url地址定向到领完一个url
web.php
Route::get('task', 'TaskController@index');
taskController
{public function index(){return "index";}}
访问task
已知是没有index路径的
web.php新增
Route::redirect('index', 'task');
访问index 会和跳转到task
他会通过302的方式跳转过来
如何设置301跳转呢
方案1
Route::redirect('index', "task", 301);
方案2
Route::permanentRedirect('index', "task");
如果拟更换域名建议使用302的方式
302代表永久性跳转。301代表临时重定向
这样有助于seo