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.

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

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元