如何在 Zend Framework 中将 URL 作为 URL 的参数传递?

发布于 2024-11-23 17:47:41 字数 1106 浏览 1 评论 0原文

我的问题源于我向用户发送一封电子邮件,内容如下:

http://mydomain.net/login/index/dest/%2Finvitation%2Fconfirm%2Fconfirmation_key%2F15116b5e4c61e4111ade679c10b3bf27

如您所见,我想要做的是将 url 作为参数“dest”传递" 这样登录页面就会知道用户登录后重定向到哪里。但是,我看到以下内容:

404 Not Found - /login/index/dest//invitation/confirm/confirmation_key/15116b5e4c61e4111ade679c10b3bf27

这是我用来创建电子邮件的视图:

<p>
<?if($this->invitation->user):?>
<a href='<?=$this->serverUrl($this->baseUrl().$this->url(array(
    'action'=>'index',
    'controller'=>'login',
    'dest'=>$this->url(array(
        'action'=>'confirm',
        'controller'=>'invitation',
        'confirmation_key'=>$this->invitation->confirmation_key
    ))
)));?>'>Log in to confirm this invitation.</a>

//The view continues...

关于如何防止翻译的任何想法将 URI 编码的项目转换为它们的字面值将不胜感激。

My question spawns from me sending an email to the user with something like the following:

http://mydomain.net/login/index/dest/%2Finvitation%2Fconfirm%2Fconfirmation_key%2F15116b5e4c61e4111ade679c10b3bf27

As you can see, what I'm trying to do is pass a url as the parameter "dest" so that the login page will know where to redirect after the user logs in. However, I'm presented with the following:

404 Not Found - /login/index/dest//invitation/confirm/confirmation_key/15116b5e4c61e4111ade679c10b3bf27

This is the View I use to create the email:

<p>
<?if($this->invitation->user):?>
<a href='<?=$this->serverUrl($this->baseUrl().$this->url(array(
    'action'=>'index',
    'controller'=>'login',
    'dest'=>$this->url(array(
        'action'=>'confirm',
        'controller'=>'invitation',
        'confirmation_key'=>$this->invitation->confirmation_key
    ))
)));?>'>Log in to confirm this invitation.</a>

//The view continues...

Any idea on how to keep this from translating the URI encoded items to their literal value would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时光无声 2024-11-30 17:47:41

不能将其作为简单的 GET 参数发送吗?

就像 http://mydomain.net/login/index/?redirect=/invitation/confirm/confirmation_key/15116b5e4c61e4111ade679c10b3bf27

实际上主要是这样完成的。

Can't you just send it over as a simpel GET parameter?

Like http://mydomain.net/login/index/?redirect=/invitation/confirm/confirmation_key/15116b5e4c61e4111ade679c10b3bf27

That's how it's mostly done actually.

何时共饮酒 2024-11-30 17:47:41
  1. ChrisR 写的绝对是答案
  2. 为什么你不直接使用 $_SERVER['referer']
  1. What ChrisR wrote is absolutly the answer
  2. Why wouldn't you just use the $_SERVER['referer']
浮云落日 2024-11-30 17:47:41

您还可以像这样升级您的链接:

<a href='<?=$this->serverUrl($this->baseUrl().$this->url(array(
'action'=>'index',
'controller'=>'login',
'dest'=>base64_encode($this->url(array(
    'action'=>'confirm',
    'controller'=>'invitation',
    'confirmation_key'=>$this->invitation->confirmation_key
))))

));?>'>登录以确认此邀请。

但是在/login/index,您将需要使用 base64_decode() 来获取原始内容 这不是最漂亮的解决方案,但如果您无法使用简单的查询字符串,这是一种方法,如何传递字符串安全地通过 URL。

http://en.wikipedia.org/wiki/Base64

You can also upgrade your link like this:

<a href='<?=$this->serverUrl($this->baseUrl().$this->url(array(
'action'=>'index',
'controller'=>'login',
'dest'=>base64_encode($this->url(array(
    'action'=>'confirm',
    'controller'=>'invitation',
    'confirmation_key'=>$this->invitation->confirmation_key
))))

));?>'>Log in to confirm this invitation.</a>

But on the /login/index, you will need to use the base64_decode() to get the original Not the most pretty solution, but if you are not able to use the simple querystring, this is a way, how to pass a string via URL safely.

http://en.wikipedia.org/wiki/Base64

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文