【问题标题】:Redirect HTTP GET method to a different url using htaccess使用 htaccess 将 HTTP GET 方法重定向到不同的 url
【发布时间】:2013-07-29 08:47:13
【问题描述】:

我知道这个问题非常基础,但如果有人可以在这里帮助我,我将不胜感激。

我正在尝试使用 htaccess 将所有请求重定向到 http://example.com/index.php?/api/functionhttp://anotherexample.com/api/function

我一直在做一些研究,我发现的只是使用 POST 方法进行重定向,但没有真正用 GET 解释。

我试过了:

RewriteBase /
RewriteRule ^index.php?/api/function http://anotherexample.com/api/function [NC,L,R=301]

这让我没有成功。 提前致谢

【问题讨论】:

标签: .htaccess redirect get


【解决方案1】:

我得到了它与上面的代码一起工作:

RewriteCond %{QUERY_STRING} ^/api/(.*)$
RewriteRule ^index.php http://anotherexample.com/api/%1? [QSA,L]

感谢 CBroe 的提示

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多