Apache 上的重定向(维护 POST 参数) [英] Redirection on Apache (Maintain POST params)

查看:40
本文介绍了Apache 上的重定向(维护 POST 参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器上安装了 Apache,我需要从 http 重定向到 https.原因是我们的负载均衡器解决方案无法处理 https,因此请求来自 http,然后我们使用 httpd.conf 文件中的以下几行将它们传输到 https.

I have Apache installed on my server and I need to redirect from http to https. The reason for this is our load balancer solution cannot hand https so requests come in on http and then we transfer them to https using the below lines in the httpd.conf file.

<VirtualHost 10.1.2.91:80>
     Redirect 302 /GladQE/link https://glad-test.com/GladQE/link.do
</VirtualHost>

这适用于 GET 请求,但 POST 请求将丢失通过 URL 传递的参数.执行此重定向和维护 POST 参数的最简单方法是什么?

This works fine for GET requests but POST requests will lose the parameters passed on the URL. What would be the easiest way to perform this redirect and maintain POST params?

我需要从 http://glad-test.com/GladQE/link.do 获取 到这里 https://glad-test.com/GladQE/link.do 维护 POST 参数

I need to get from http://glad-test.com/GladQE/link.do to here https://glad-test.com/GladQE/link.do maintaining POST params

谢谢

汤姆

推荐答案

标准 Apache 重定向将无法处理 POST 数据,因为它们在 URL 级别工作.POST 数据在请求正文中传递,如果您执行标准重定向,它会被丢弃.

Standard Apache redirects will not be able to handle POST data as they work on the URL level. POST data is passed in the body of the request, which gets dropped if you do a standard redirect.

您可以选择使用 PHP 脚本透明地转发 POST 请求,或者使用重写 (mod_rewrite) 和代理 (mod_proxy) 模块的组合Apache 如下:

You have an option of either using a PHP script to transparently forward the POST request, or using a combination of Rewrite (mod_rewrite) and Proxy (mod_proxy) modules for Apache like follows:

RewriteEngine On
RewriteRule /proxy/(.*)$ http://www.example.com/$1 [P,L]

P 标志将请求传递给代理模块,因此任何到达您网站的内容(通过 GET 或 POST 都无关紧要)且 URL 路径以 /proxy/开头 将透明地作为代理重定向到 http://www.example.com/ 处理.

P flag passes the request to the Proxy module, so anything that comes to your site (via GET or POST doesn't matter) with a URL path starting with a /proxy/ will transparently be handled as a proxy redirect to http://www.example.com/.

供参考:

这篇关于Apache 上的重定向(维护 POST 参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆