重定向POST htaccess的 [英] Redirect POST htaccess
问题描述
这个问题是非常相似:<一href="http://stackoverflow.com/questions/358263/htaccess-is-it-possible-to-redirect-post-data">.htaccess - ?是否可以重定向后的数据(问早期的教),但这个问题的答案似乎并没有为我工作。
This question is very similar to: .htaccess - Is it possible to redirect post data? (asked eariler) but that answer does not seem to work for me.
我有一个表格:
<form action="http://a.test.com/contact" name="contact" method="post">
和一个附加域里面,(test.com是一个插件),有一个子域(A),以及里面有我有一个文件item.php,和.htaccess
and inside of a add-on domain, (test.com is an addon), there is a subdomain (a.), and inside of there I have a file item.php, and .htaccess
我的htaccess如下:
my htaccess is as follows:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
#normal rewrites
RewriteRule ^[~|-]?([a-zA-Z0-9]+)[/]*$ item.php?user=$1 [NC,L]
请注意:我把它作为[NC,L],因为当我把它改为[NC,P]它给了我500服务器错误
note: I left it as [NC,L] because when I changed it to [NC,P] it gives me a 500 server error.
和我item.php
and my item.php
<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";
和无论什么形式的包含中,$ _ POST是空白......但是,如果我做 HTTP: //a.test.com/item.php?user=contact 作为动作。
and no matter what the form contains, the $_POST is blank... however, if I do http://a.test.com/item.php?user=contact as the action.
一切顺利。发布跳过htaccess的,并因此该解决方案似乎并没有工作。
all goes well. POSTing skips the htaccess, and the solution on SO doesn't seem to work.
在此先感谢
推荐答案
您加斜线规则强制的头重定向:
Your "add trailing slash" rule forces a header redirect:
[R=301,L]
一个头重定向将下降POST值。
a header redirect will drop POST values.
您将不得不放弃该规则,或禁止其用于POST提交:
You will have to drop that rule, or disable it for POST submissions:
# Forces a trailing slash to be added
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
这篇关于重定向POST htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!