magento 跳转
Magento: Redirect functions
原文:http://blog.chapagain.com.np/magento-redirect-functions/
The redirect functions are present in Mage_Core_Controller_Varien_Action class.
/* Redirect to certain url */
_redirectUrl($url)
/* Redirect to certain path */
_redirect($path, $arguments=array())
/* Redirect to success page */
_redirectSuccess($defaultUrl)
/* Redirect to error page */
_redirectError($defaultUrl)
/* Set referer url for redirect in response */
_redirectReferer($defaultUrl=null)
/* Identify referer url via all accepted methods (HTTP_REFERER, regular or base64-encoded request param) */
_getRefererUrl()
/* Check url to be used as internal */
_isUrlInternal($url)
Example:
You can use the redirect functions in your controller class. Like below:-
$this->_redirect($path, $arguments=array());
// OR,
$this->_redirectUrl($url);
1
2
3
$this->_redirect($path, $arguments=array());
// OR,
$this->_redirectUrl($url);
The other way is:-
For redirect URL:-
$url = "http://example.com";
Mage::app()->getFrontController()->getResponse()->setRedirect($url);
1
2
$url = "http://example.com";
Mage::app()->getFrontController()->getResponse()->setRedirect($url);
For redirect with path and arguments:-
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl($path, $arguments));
1
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl($path, $arguments));
Hope it helps. Thanks.
Related Posts:
- Magento: Redirect Customer to Previous Page After Login
- Magento: Redirect Customer to Login page if not logged in
- Magento: Very Useful Collection Functions
- Magento: Use MySQL functions with addExpressionAttributeToSelect
- Magento: How to get controller, module, action and router name?
- Magento: Rewrite/Override Block Controller Model Helper
- Google Social Connect: Redirect URI mismatch error
- Running Magento 1.3 and older versions in PHP 5.3
- Magento: Create, Read, Delete Cookie
- Magento: Add new tab to Customer Account Section
原文:http://blog.csdn.net/yy20071313/article/details/43852879
$this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
$this->getResponse()->setHeader('Status','404 File not found');
$this->_forward('defaultNoRoute');
#magento# 之 redirectuRL
http://blog.sina.com.cn/s/blog_6ea2cfe40101e1er.html
1.
protected function _redirect($path, $arguments = array())
{
return $this->setRedirectWithCookieCheck($path, $arguments);
}
2.
protected function _redirectError($defaultUrl)
{
$errorUrl = $this->getRequest()->getParam(self::PARAM_NAME_ERROR_URL);
if (empty($errorUrl)) {
$errorUrl = $defaultUrl;
}
if (!$this->_isUrlInternal($errorUrl)) {
$errorUrl = Mage::app()->getStore()->getBaseUrl();
}
$this->getResponse()->setRedirect($errorUrl);
return $this;
}
3.
protected function _redirectReferer($defaultUrl=null)
{
$refererUrl = $this->_getRefererUrl();
if (empty($refererUrl)) {
$refererUrl = empty($defaultUrl) ? Mage::getBaseUrl() : $defaultUrl;
}
$this->getResponse()->setRedirect($refererUrl);
return $this;
}
4.
protected function _redirectSuccess($defaultUrl)
{
$successUrl = $this->getRequest()->getParam(self::PARAM_NAME_SUCCESS_URL);
if (empty($successUrl)) {
$successUrl = $defaultUrl;
}
if (!$this->_isUrlInternal($successUrl)) {
$successUrl = Mage::app()->getStore()->getBaseUrl();
}
$this->getResponse()->setRedirect($successUrl);
return $this;
}
5.
protected function _redirectUrl($url)
{
$this->getResponse()->setRedirect($url);
return $this;
}
6.
protected function _rewrite()
7.
protected function _getRefererUrl()
{
8.
protected function _forward($action, $controller = null, $module = null, array $params = null)
{
#############example################
Mage::app()->getFrontController()->getResponse()->setRedirect('http://www.google.com');
magento 跳转的更多相关文章
- magento 自定义url路径 和 filter data 小结
背景是往一个第三方的搜索插件里面加入filter功能. 首先是路径,插件自己定义了一个router,类似于cms.那首先说说router好了,从入口一路追查的话,会发现最后进入的是Mage_Core_ ...
- 安装完magento后,其他电脑无法访问magento,URL自动跳转到http://localhost/magento
问题:在电脑A上安装完了magento 1.7.0.2 然后, 在电脑A上用 http://localhost/magento 访问网站,没有问题. 但在电脑B 上用 http://192.168.4 ...
- 【解决方法】magento paypal快速结账 不跳转
magento paypal Express Checkout(快速结账) 页面不跳转到Paypal的解放方法 我使用的magento 1.9.0.1 版本的,Paypal 快速结账都已经设置完毕,但 ...
- magento产品成功添加到购物车后跳转到不同页面 添加 add to cart 按钮
1 添加产品到购物车成功后是跳转到购物车页面或不跳转.这个在后台可以设置 system -> configuration -> After Adding a Product Redirec ...
- magento getUrl函数跳转admin模块问题
在用以下代码时,跳转后的url里面会是空的,即没有admin这个值 $this->getUrl('admin/catalog_product/edit', array('id' => $c ...
- magento后台登陆后,没任何提示,又跳转到登陆页面
这个问题通常是cookie配置的问题.需要去将core_config_data中web/cookie/cookie_path.web/cookie/cookie_domain设为null
- LNMP环境magento常见错误
一.安装报404错误 git clone 下最新代码,跳转到index/install 安装时出现404错误 需要把伪静态规则加到nginx配置文件中: # # The default server ...
- magento后台paypal设置
如何在magento后台设置paypal呢? 这边把整理的简单跟大家分享一下. 1.system->config-paypel1.1 Merchant Country 设置国家1.2 Email ...
- magento cache,magento index
"Magento后台作修改,Magento前台没变化""Magento属性更新了,Magento前台没反应"如果你碰到了以上两种情况,或者看到截图中的提示: 您 ...
随机推荐
- mongoose 数据库连接
1安装mongoose npm install mongoose 安装成功 2.打开数据库 mongod --path E:\mongo 成功 创建一个db.js var mongoose = req ...
- Oracle多表更新及MERGE命令和闪回机制还原数据表
一.多表更新 比如线上有个系统由于某一个模块出现异常,导致系统整体的数据出现了错误,需要你手动改写数据库错误,Oracle update语句更新的值来自另一张表 update语法最基本的格式为 UPD ...
- push declined due to email privacy restrictions
使用git push到Github网站的时候提示: push declined due to email privacy restrictions 原因 在Github设置里有一个隐私选项 Block ...
- leetcode-12双周赛-1245-树的直径
题目描述: 方法一:深度优先: class Solution: def treeDiameter(self, edges: List[List[int]]) -> int: adjacency ...
- 对称性——cf405d
以后碰到这种题就应该往对称性想:设x的对称数x‘是1e6-x+1 对于任意一组对称数x+x'-2=1e6-1,2e6-(x+x')=1e6-1,即X集合Y集合同时加上任意一组对称数都是可以的 枚举每个 ...
- linux环境下安装PHP的OpenSSL扩展
先安装依赖包:yum install openssl openssl-devel 进入PHP安装包里的OpenSSL文件夹,根据个人的安装包位置不同,此处是 cd /home/local/php.5. ...
- mui-scroll-wrapper mui-scroll 内容增多不出滚动条
滚动条需要初始化 mui('.mui-scroll-wrapper').scroll({});
- AcWing 201. 可见的点 (欧拉函数打表)打卡
在一个平面直角坐标系的第一象限内,如果一个点(x,y)与原点(0,0)的连线中没有通过其他任何点,则称该点在原点处是可见的. 例如,点(4,2)就是不可见的,因为它与原点的连线会通过点(2,1). 部 ...
- php编译安装增加pdo扩展
首先查看mysql版本和位置 mysql --version whereis mysql 去php安装目录安装扩展 cd /usr/local/src/php-5.4.25/ext/pdo_mysql ...
- android ellipsize的使用及实现跑马灯效果总结
参考资料: http://blog.csdn.net/huiwolf2008/article/details/7901084 http://www.cnblogs.com/Gaojiecai/arch ...