php - Laravel 获取重定向地址
问题描述
我在获取 Laravel URL 时遇到问题。
我有一个页面,如果用户未登录,它将用户重定向到错误的 url 并给出错误。
我redirect()->intended($this->redirectPath());
用来让用户在登录后回到他在页面上的位置,所以我必须以某种方式编写代码来检查什么是重定向 URL,如果它是会给出错误的 URL,
我知道 URL 是什么,它必须将用户重定向到我需要设置的另一个 URL。
我尝试了不同的方法
$this->redirectPath() == 'here goes the url'
和喜欢
redirect()->intended($this->redirectPath()) == 'again url here'
但没有任何效果。
解决方案
尝试这个:
return Redirect::intended('here goes the url');
或者
return Redirect::intended();
intended()
检查会话索引 url.intended 是否存在并默认重定向到它,否则重定向到可以覆盖的 $default='/'。
推荐阅读
- reactjs - 我想知道一些关于 webpack 的事情(使用 react)
- html - 如何在角度数据表中添加图像从项目文件夹自定义按钮打印
- azure - 使用 Microsoft Identity 获取 Graph 和 Azure DevOps API 的唯一令牌
- javascript - 接受一个数组和用逗号分隔的参数并返回一个返回任意数字的函数的函数
- reactjs - object.key 用于在地图上使用对象作为数组,而不是将参数作为道具传递给 React 组件
- wordpress - 更改运输方式不会更新结帐页面中的购物车总价格
- java - 如何解决错误:本机内存分配 (mmap) 未能映射 65536 字节以提交保留内存
- c# - 如何在 C# 中的覆盖 ToString 方法中包含 void 方法
- ios - 图表 - ScatterChart 1:1 轴比例
- apache-spark - 自定义 Spark 聚合器返回 Row