apache - Apache 2.4 如何仅重定向精确的 php 文件 - 但不是正常查询
问题描述
在我看来这很简单,但我仍然没有找到答案。
在 Apache 2.4 下,我需要将所有请求重定向到 http://example.com/data/request.php到http://example.com/info.html 这很简单
RedirectMatch .*/request.php http://example.com/info.html
但我需要保持所有正常查询不变(如下所示)
http://example.com/data/request.php?id=26561
但使用 RedirectMatch 规则,所有正常查询也会重定向到
http://example.com/info.html?id=26561
感谢您尝试任何想法,
解决方案
谢谢上面@Capsule的提示-可能有人需要针对我的示例的确切答案
为了正确的重定向,我们必须使用
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/?request.php$ http://example.com/info.html? [L,R]
它只重定向确切的
http://example.com/data/request.php
但留下完整的查询,如
http://example.com/data/request.php?id=26561
推荐阅读
- javascript - 在 vuejs 中填写所有字段后更改按钮颜色的问题?
- html - 如何使用引导网格使 3 个 div 居中
- c# - 点燃对非匿名类型的 LINQ 提供程序投影支持
- ios - Observablesubscriber.onError 在 Debug 中导致 fatalException
- node.js - npm 发布失败,并显示““路径”参数必须是字符串类型。收到未定义”
- python - 选择额外元素的 HTML 页面的子选择上的 XPath?
- sql - 为另一列的每个值选择一列的顶部 1
- python - 使用公共列映射两个数据框
- hibernate - 使用 org.geolatte.geom 构造 LineString
- jenkins - 如何在脚本化的詹金斯管道中定义全局变量