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前台没反应"如果你碰到了以上两种情况,或者看到截图中的提示: 您 ...
随机推荐
- 使用openntpd替换ntpd
系统自带的ntp服务太难用,systemd启动几次没启动起来,懒得折腾,换了openntpd一次成功.
- linux配置java环境变量(详细)(转)
linux配置java环境变量(详细) 一. 解压安装jdk 在shell终端下进入jdk-6u14-linux-i586.bin文件所在目录, 执行命令 ./jdk-6u14-linux-i586. ...
- input | button | textarea 元素的checked, disabled,hidden属性控制
这三种元素涉及到的checked, disabled,hidden属性的控制方法如下 一.attribute方法: //以下3行,都会影响HTML的( checked | disabled | hid ...
- 用CleanMyMacX怎样进行邮件附件清理,CleanMyMacX清理邮件附件的方法
都晓得CleanMyMacX邮件附件清理功能十分强大,用CleanMyMacX怎样进行邮件附件清理,CleanMyMacX清理邮件附件的方法带给你,邮件附件清理功能可以保证在收件箱中原始附件的安全性的 ...
- 如何在webpack中使用loader
一.什么是loader loader 用于对模块的源代码进行转换.loader 可以使你在 import 或"加载"模块时预处理文件.因此,loader 类似于其他构建工具中“任务 ...
- Yii2 搜索
搜索的形式: 第一种,点击空白处: <?php $data=['0'=>'已删除','10'=>'正常','1'=>'锁定']; ?> <table style=' ...
- 【LeetCode 7】整数反转
题目链接 [题解] 没什么说的. 就注意一点. 可以在*10+n%10的时候. 顺便判断有没有溢出. (直接用longlong可真是机制..) [代码] class Solution { public ...
- 使用 windsor 实现IOC 和 AOP
代码很简单,不多说. 对于拦截,windsor 使用动态代理的方式,即生成继承类的方式来实现的,因此无法拦截private 方法,因为无法在继承类中看见private方法. using System; ...
- Java异常关闭资源的两种方式
try-catch-finally 常用,在异常关闭时应判断流是否为空 public class CloseableUtils { public static void closeable(Close ...
- SQL中Truncate语法
转自:http://www.studyofnet.com/news/555.html 本文导读:删除表中的数据的方法有delete,truncate, 其中TRUNCATE TABLE用于删除表中的所 ...