douchenchepan6465 2014-02-12 08:25
浏览 18
已采纳

在opencart中限制多用户环境中的控制器/功能访问

I am doing some changes to my opencart site. in my case, its a multi-store

www.mywebsite.com - 1st store

store.mywebsite.com - 2nd store

What I want to do is restrict users of the first store from accessing

http://www.mywebsite.com/index.php?route=account/order

and if accessed redirect them to

http://store.mywebsite.com/index.php?route=account/order

or show an error so that account/order is only accessible through the sub-domain, http://store.mywebsite.com

I tried to add the below code as the constructor. But no luck

    public function __construct() {
        global $registry;
        parent::__construct($registry);

        if($_SERVER['HTTP_HOST'] == 'http://mywebsite.com' || $_SERVER['HTTP_HOST'] == 'http://www.mywebsite.com')
            {
            $this->url->redirect($this->url->link('http://store.mywebstore.com/index.php?route=account/order', '', 'SSL'));
            }

    }

can someone help me with this?

  • 写回答

1条回答 默认 最新

  • dtdb99743 2014-02-12 09:23
    关注

    I shouldn't reccomend a redirect with .htaccess, opencart has this kind of actions by default, what i have used before is add this line of code in corresponding controller:

    if($data['store_id'] != "destination_store_id"){
      $this->redirect($this->url->link('http://store.mywebstore.com/index.php?route=account/order', '', 'SSL'));    
    }
    

    this should work just fine, by my opinion.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。