【发布时间】:2013-07-29 08:47:13
【问题描述】:
我知道这个问题非常基础,但如果有人可以在这里帮助我,我将不胜感激。
我正在尝试使用 htaccess 将所有请求重定向到 http://example.com/index.php?/api/function 到 http://anotherexample.com/api/function
我一直在做一些研究,我发现的只是使用 POST 方法进行重定向,但没有真正用 GET 解释。
我试过了:
RewriteBase /
RewriteRule ^index.php?/api/function http://anotherexample.com/api/function [NC,L,R=301]
这让我没有成功。 提前致谢
【问题讨论】:
-
RewriteRules 仅适用于 URL 的路径组件,而不适用于查询字符串。如果您还想评估查询字符串,请在 RewriteRule 之前使用 RewriteCond。 httpd.apache.org/docs/2.2/en/mod/mod_rewrite.html#rewritecond