【发布时间】:2009-11-27 00:01:57
【问题描述】:
我似乎无法通过 POST 使用 PHP over SSL 提交表单。快速浏览一下我的代码,谁能告诉我有什么问题?
我的 .htaccess 文件
RewriteEngine On
RewriteBase /test
RewriteCond %{HTTP_HOST} !^www\.helloworld\.org$ [NC]
RewriteRule ^(.*)$ http://www.helloworld.org/test/$1 [L,R=301]
# If i comment out these 3 lines, everything works fine
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (myaccount|register|registration|login)
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
这里是 index.php
<?php $myurl = "http://www.helloworld.org".$_SERVER['REQUEST_URI']; ?>
<form method="post" action="<?=$myurl ?>">
<input name="text" />
<input type="submit" />
<?php print_r($_POST); ?>
我采取以下行动:
1) 转到http://www.helloworld.org/test/login/(我的浏览器会自动显示https版本)
2) 我在表单中输入一些内容并点击提交按钮
3) print_r($_POST) 什么也不打印!我预计它会被填充!
如果我注释掉 .htaccess 文件中与 HTTPS 相关的三行并重复相同的实验,那么 print_r($_POST) 会给我表单提交的结果。
如何让我的表单发布始终有效?
【问题讨论】:
-
您是否尝试过使用 307 而不是 301 是否会导致其行为不同?