duanji5569 2014-03-24 13:02
浏览 45
已采纳

通过htaccess重定向到另一个页面而不是index.php

When first time load the page instead of index page it should redirect to another page. After that when we clicked on home page then it will redirect to home page. I have done through htaccess. And I wanted to open database link also so I put below code.

DirectoryIndex inventory.php

< IfModule mod_rewrite.c >
  RewriteEngine on
  Rewriterule ^mega_dados/.*$ - [PT]
</IfModule >

Above code is working only for first time page load but rewrite rule is not working. If I'll comment first line then rewrite rule is working but directory index is not working. But I wanted both. How can I resolve it.

  • 写回答

2条回答 默认 最新

  • douyiavxxh02727 2014-03-24 13:11
    关注

    Depends what you need exactly, i use cookies to redirect you at first visit. By the first visit, index.php will not find a cookie and goes to start.php

    index.php:

    <?php
        if (!isset($_COOKIE['MYcookie'])) {
            header("Location: ./start.php");
            exit();
        }
    ?>
    

    start.php:

    <?php 
      if (!empty($_POST['waarde'])) 
      {  
            setcookie ('MYcookie', 'yes', time() + 3600);
            header("Location: ./index.php");
            exit();
      }
    ?>
    
          <form method="post" action="">
          <input type="radio" name="waarde" value="1" checked="checked"><b>YES</b>
          <input type="radio" name="waarde" value="0"><b>NO</b>
          <input class="mybuttons" type="submit" value="ACCEPT">
          </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测