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前台没反应"如果你碰到了以上两种情况,或者看到截图中的提示: 您 ...
随机推荐
- vue插件安装
百度云下载插件 https://pan.baidu.com/s/13QhPilzJa8yu3HvKCt47Pw 学习Vue.js时,Chrome浏览器安装Vue.js devtool能很方便的查看 ...
- C# 16进制转字符串,字符串转16进制
{ //========================================================== //16进制转字符串 public static byte[] HexTo ...
- JMeter4.0 IF Controller
推荐使用 __jexl3 函数生成 if controller判断条件 举个栗子: 1. 假如条件为 "${demo}" == "test" 2. 在If Co ...
- PHP ftp_get_option() 函数
定义和用法 The ftp_get_option() 函数返回 FTP 连接的各种运行时选项. 语法 ftp_get_option(ftp_connection,option) 参数 描述 ftp_c ...
- (转)NAT与NAT穿越学习总结--ICE过程讲的不错
转:http://cgs1999.iteye.com/blog/1994072 1.引言网络地址转换(Network Address Translation,简称NAT)是一种在IP分组通过路由器或防 ...
- JS 变量 相关内容
JS变量按存储方式区分为哪些类型?: js变量按照存储方式分为两种类型:值类型 和 引用类型 1.值类型(基本类型): 布尔值(boolean) . null .undefined .数值(numbe ...
- 搭建hadoop集群 单机版
二.在Ubuntu下创建hadoop用户组和用户 这里考虑的是以后涉及到hadoop应用时,专门用该用户操作.用户组名和用户名都设为:hadoop.可以理解为该hadoop用户是属于一 ...
- 正则表达式Pattern类的基本用法
public void mailRegex() { // 要验证的字符串 String str = "shiruo.hdp@taobao.com"; // 邮箱验证规则 Strin ...
- 前端(十一)—— JavaScript基础:JS存在的位置、JS变量定义、调试方式、JS数据类型、运算符
JS存在的位置.JS变量定义.调试方式.JS数据类型.运算符 一.JS语言介绍 1.概念 浏览器脚本语言 可以编写运行在浏览器上的代码程序 属于解释性.弱语言类型编程语言 2.组成 ES语法:ECMA ...
- Windows7下命令行使用MySQL
我在Win7下安装的MySQL版本是mysql-5.0.22-win32 1.在Win7环境下安装MySQL,关于安装方法可以参考文章: Win7系统安装MySQL5.5.21图解教程.win7安装M ...