doudun1029 2014-04-11 06:24
浏览 42
已采纳

Joomla 2.5主页重定向问题

I want to set joomla site to redirect visiting users to registration page if my cookie is not set. I've put below code in top of the (after imports) template index.php file.

if (empty($_COOKIE["abc"])){   
    $app = &JFactory::getApplication();    
    $link = "index.php?option=com_users&view=registration";
    $app->redirect($link);
   exit();
}

URL is redirect but it is going in loop. so page not loading correctly. This is fire bug screen shot enter image description here

How to omit this loop ? Thanks.

  • 写回答

3条回答 默认 最新

  • dongyan5815 2014-04-11 06:43
    关注

    Your problem because of your code. You put your code on top of page... your redirection to registration page is correctly but when page goes to registration page.. at that time this code also check because it is on top of index file.. so again redirect on registration page.

    So, loop continue redirecting...then i think issue create.

    Put condition on your code with cookies like below,

    if (empty($_COOKIE["abc"]) && empty($_COOKIE['is_redirected']) && (new condition)){ 
    
    • new condition: above replace new condition with check your page is not login or register what you want.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化