htaccess的 - 是否有可能重定向后的数据?有可能、重定向、数据、htaccess

2023-09-02 00:19:30 作者:他夏了夏天

我有一个网站,所有的请求都默默的重定向(通过的.htaccess)到的index.php,然后PHP是用来显示正确的页面(通过遍历REQUEST_URI)。

我在想,如果有可能的POST数据提交到假地址呢?

目前我已经得到了我的表像这样

 <形式的行动=/ whatplant /发送邮件的方法=后ID =接触美的形式>
 

和我的.htaccess规则

 #重定向邮件张贴到指数
     重写规则发送邮件的index.php?发送邮件[NC,L]
 

我的index.php检查使用isset($ _ GET ['发送邮件']),工作正常。

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

有没有一种方法,以保持后的数据?我不希望使用GET,因为它不能发送尽可能多的信息,虽然它可能不是一个问题,一个简单的查询表。

rewirte伪静态的虚拟主机是否支持301重定向 也就是是否支持.htaccess文件

感谢您!

编辑:我改变了形式的行动,以一个test.php的用的print_r($ _ POST),并得到正确的输出。我仍然有接收后的数据问题时动作发送到的index.php

下面是我的.htaccess重定向到index.php

 #文件服务解决方案,并显示目录如果存在的话,请,否则发送到指数
    的RewriteCond%{} REQUEST_FILENAME!-d
    的RewriteCond%{} REQUEST_FILENAME!-f
    重写规则。的index.php
 

解决方案

试试这个:

 #重定向邮件张贴到指数
     重写规则发送邮件的index.php?发送邮件[NC,P]
 

P的行为像L,它停止处理规则,却也道出了请求应该被传递给代理模块完整的模块(意为POST数据是preserved)。

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 traversing the REQUEST_URI).

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="/whatplant/send-mail" method="post" id="contact-us-form">

And my .htaccess rule is

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

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

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

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 enquiry form.

Thank you!

EDIT: I changed the form's action to a test.php with print_r($_POST) and got the correct output. I am still having problems receiving the post data when the action is sent to 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

解决方案

Try this:

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

"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).