是否可以重定向帖子数据? [英] Is it possible to redirect post data?

查看:19
本文介绍了是否可以重定向帖子数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,其中所有请求都以静默方式(通过 .htaccess)重定向到 index.php,然后使用 PHP 显示正确的页面(通过解析REQUEST_URI).

I have a website where all requests are redirected silently (via .htaccess) to index.php and then PHP is used to show the correct page (by parsing the REQUEST_URI).

我想知道是否也可以将 POST 数据提交到假地址?

I was wondering if it's possible to submit POST data to a fake address too?

我目前的表格是这样的...

I've currently got my form like so...

<form action="/send-mail" method="post">

而我的 .htaccess 规则是...

And my .htaccess rule is...

# redirect mail posting to index
RewriteRule send-mail index.php?send-mail [NC,L] 

我的 index.php 检查 isset($_GET['send-mail']) 是否工作正常.

My index.php checks isset($_GET['send-mail']) which works fine.

然而,这似乎丢弃了所有应该发送给它的 POST 数据.

This however seems to drop off all the POST data that should be sent to it.

有没有办法保留帖子数据?我不想使用 GET,因为它不能发送尽可能多的信息,尽管它可能不是一个简单的查询表单的问题.

Is there a way to keep the post data? I don't want to use GET because it can't send as much information, though it might not be an issue with a simple inquiry form.

这是我的 .htaccess 用于重定向到 index.php

Here is my .htaccess for redirecting to index.php

# serve files and dirs if they exist please, otherwise send to index
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php

推荐答案

试试这个:

# redirect mail posting to index
     RewriteRule send-mail index.php?send-mail [NC,P]

P"的作用类似于L",因为它停止处理规则,但它也告诉模块应该将请求完整地传递给代理模块(意味着 POST 数据被保留).

"P" acts like "L" in that it stops processing rules but it also tells the module that the request should be passed off to the proxy module intact (meaning POST data is preserved).

这篇关于是否可以重定向帖子数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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