首页 > 解决方案 > 我想从根路径 /index.php 重定向到 index.php?page=terms

问题描述

我正在更改 .htaccess 文件以将根路径 (/) 更改为 index.php?page=terms

重定向 /index.php /index.php?page=terms

但它显示错误重定向太多次

标签: php.htaccess

解决方案


您是否尝试过更改索引页面的名称?例如,重定向 fromindex.phphome.php?page=terms 页面可能会重定向所有index.php页面(包括index.php?page=terms),因为毕竟它是同一个页面,只是在 URL 中有一点点 GET 信息。

或者,您可能只想使用类似的东西:

    if(!isset($_GET["page"])){
      header("Location: index.php?page=terms");
    }

?page=如果不存在,它将重定向。这不需要任何.htaccess更改。


推荐阅读