热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Laravel重定向301与302

重定向就是从一个url地址定向到领完一个urlweb.phpRoute::get(task,TaskControllerindex);taskController

重定向 就是从一个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


推荐阅读
author-avatar
真正的爱情是什么2010
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有