php - 我想从根路径 /index.php 重定向到 index.php?page=terms
问题描述
我正在更改 .htaccess 文件以将根路径 (/) 更改为 index.php?page=terms
重定向 /index.php /index.php?page=terms
但它显示错误重定向太多次
解决方案
您是否尝试过更改索引页面的名称?例如,重定向 fromindex.php
到home.php?page=terms
页面可能会重定向所有index.php
页面(包括index.php?page=terms
),因为毕竟它是同一个页面,只是在 URL 中有一点点 GET 信息。
或者,您可能只想使用类似的东西:
if(!isset($_GET["page"])){
header("Location: index.php?page=terms");
}
?page=
如果不存在,它将重定向。这不需要任何.htaccess
更改。
推荐阅读
- amazon-web-services - SonarQube 没有在 EFS 上使用 AWS EKS Fargate
- outlook-2016 - 是否可以在使用 Outlook 2016 发送的电子邮件中附加和嵌入小视频?
- angular - 为什么 Identity Server logoutId 总是为空?
- swift - 如何在 iOS 网络扩展中解析数据包
- c++ - C++ 使用 KeccakCode 包
- jmeter - 使用 JMETER 在非 gui 模式下启动分布式负载测试时出错
- visual-studio-2019 - 如何在 VisualStudio 2019 中重置可视化编辑器缩放?
- sql - 用户定义的表类型的数据类型无效
- python - 为什么 tesseract 不能提取具有黑色背景的文本?
- julia - 如何将@time 的输出存储到变量中?