传递参数时重定向 [英] Pass parameters when redirect
问题描述
我有哪里的链接用户点击接收到的要求有迹象电子邮件中的场景。如果链接 http://test.url.com/product/2
,用户应登录和页面应该验证后重定向到相同的路径。
I have a scenario where the user clicks on a link received to an email which requires a sign in. if the link is http://test.url.com/product/2
, the user should sign in and the page should redirect to the same path after authentication.
我试着通过使用来解决这个的print_r($请求 - >包头中>获取('引荐'));
这张贴的问题在这里: <一href=\"http://stackoverflow.com/questions/27792100/redirect-to-the-url-of-the-clicked-refered-link\">Redirect到点击(所指向)链接的URL。这是不成功的,因为它返回null。
I tried to tackle this via the use of print_r($request->headers->get('referer'));
which posted a question here : Redirect to the url of the clicked (refered) link . which was unsuccessful as it returned null.
我的下一个目标是根据URL参数传递到登录页面。
My next aim is to pass parameters to the sign in page depending on the url.
例如:如果用户点击 http://test.url.com/product/2
,在URL符号看起来像 HTTP ://test.url.com/signin/product/2
或 http://test.url.com/signing?=pruduct?2
或类似的东西,其中该系统将用户重定向到所需的页面。
eg: if the user clicks http://test.url.com/product/2
, the sign in url would look like http://test.url.com/signin/product/2
or http://test.url.com/signing?=pruduct?2
or something like that where the system would redirect the user to the desired page.
从配置层面传递参数的任何文件/例子是大大pciated因为我很新的这域名AP $ P $。感谢:)
Any document/ example on passing parameters from the config level is greatly appreciated as I am very new to this domain. thanks :)
推荐答案
我会建议提重定向URL作为登录URL查询字符串如
I would suggest to mention the redirect url as a query string on the login url like
http://test.url.com/signin/?redirect=http://test.url.com/product/2
成功登录之后你需要做的就是
Upon a successful login all you have to do is
$url=$_GET['redirect'];
header("location:".$url);
这篇关于传递参数时重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!