某些页面上的 https 请求,但不是所有页面上的 Zend 框架 [英] https request on some pages but not on all pages zend framework
问题描述
我需要将 https 放在某些 URL 上,而不是放在所有 URL 上.我正在为所有链接使用 zend URl 视图助手.我有一个用于整个站点的 *.example.com SSL 证书.现在我用 https://www.example.co 打开网站,然后在主页或其他页面在 URL 中包含 https.如何在 https url 上做一些特定的请求,其他页面应该可以正常打开.
I need to put https on some of the URL but not on all the URL. I am using zend URl view helper for all the links. I have a *.example.com SSL certificate for whole site. Now I open site with https://www.example.co, then all the link on home page or other pages contains https in URL. How can I make some specific request on the https url and other page should be opened normal.
我还需要进行一些重定向,以便如果有人在正常 URL 中打开特定页面,那么他们会在 https url 上重定向.我认为 .htaccess 重定向可以解决这个问题.
I also need to pt some redirection so that if somebody open the specific pages in normal URL then they redirected on https url. I think the .htaccess redirection will work for that.
任何帮助????
提前致谢!!!
推荐答案
我宁愿使用一种简单的方法,它不需要对 url 生成/路由进行任何更改.我在插件的 routeStartup 函数中写了以下几行,并且没有对 URL 路由进行任何更改.
I rather used a simple method and that does not required any change in urls generation/route. I wrote following lines in routeStartup function of a plugin and haven't made any change in URLs route.
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
$controller=$this->_controller = $this->_front->getRequest()->getControllerName();
$action=$this->_controller = $this->_front->getRequest()->getActionName();
if($_SERVER['SERVER_PORT']!=443)
{
//controller and actions array to check ssl links
$actionArr=array('index'=>array('registration'),'account'=>array('editacc','edit'),'dealer'=>array('*'));
if(array_key_exists($controller,$actionArr)!==false)
{
if(in_array($action,$actionArr[$controller]) || $actionArr[$controller][0]=='*')
{
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->gotoUrl(SITE_LIVE_URL_SSL.$controller."/".$action);
}
}
}
else
{
//controller and action array that should not be on ssl.
$notAactionArr=array('usersearch'=>array('mainserarch'),'account'=>array('index'),'onlineusers'=>array('*'));
if(array_key_exists($controller,$notAactionArr)!==false)
{
if(in_array($action,$notAactionArr[$controller]) || $notAactionArr[$controller][0]=='*')
{
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->gotoUrl(SITE_LIVE_URL.$controller."/".$action);
}
}
}
}
这篇关于某些页面上的 https 请求,但不是所有页面上的 Zend 框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!