如何在 Zend Framework 中将 URL 作为 URL 的参数传递?
我的问题源于我向用户发送一封电子邮件,内容如下:
如您所见,我想要做的是将 url 作为参数“dest”传递" 这样登录页面就会知道用户登录后重定向到哪里。但是,我看到以下内容:
这是我用来创建电子邮件的视图:
<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:
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:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不能将其作为简单的 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.
$_SERVER['referer']
$_SERVER['referer']
您还可以像这样升级您的链接:
));?>'>登录以确认此邀请。
但是在
/login/index
,您将需要使用base64_decode()
来获取原始内容 这不是最漂亮的解决方案,但如果您无法使用简单的查询字符串,这是一种方法,如何传递字符串安全地通过 URL。http://en.wikipedia.org/wiki/Base64
You can also upgrade your link like this:
));?>'>Log in to confirm this invitation.</a>
But on the
/login/index
, you will need to use thebase64_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