doww38701 2011-10-21 21:29
浏览 32
已采纳

如何使用我的.htaccess规则保留$ _POST?

I have a this .htaccess rule for my lease form

RewriteRule ^(lease)$ index.php?route=$1 [L]

which i am using with this PHP to file the proper file

$industries = array();
while($row_r = mysql_fetch_assoc($result)){
  $industries[] = $row_r;
}
if(isset($_REQUEST['route'])){
    $route = rtrim($_REQUEST['route'], '/');
    $home_page = ($route == '') ? true : false;
    $parts = explode('/', $route);
}else{
    $home_page = true;
}
if(!$home_page){
    include($_SERVER['DOCUMENT_ROOT'] . '/inc/routes.php');
}

routes.php file

 $valid_pages = array('newsletter_subscribe', 'lease',....

$file = $parts[count($parts) - 1];
if (in_array($file, $valid_pages)) {
 include($_SERVER['DOCUMENT_ROOT'] . "/pages/$file.php");
exit;
}else{
include($_SERVER['DOCUMENT_ROOT'] . "/pages/404.php");
exit;

this works great and i an getting to a pages/lease.php file. All is good but on the lease.php file i have a form that posts to itself like this

<?php  if((isset($_POST['submitform'])) && ($_POST['submitform'])) {
   echo "<pre>".print_r($_POST)."</pre>";
}

<form action="/pages/lease.php" method="post" id="app_form" name="app_form" onsubmit="return checkForm();">
<input type="text" name="print_config" value="email">
<p><input type="submit" name="submitform" value="Submit Application"></p>
....

BUT the POST is always empty...why is that and how do I preserve it..am I missing something

  • 写回答

1条回答 默认 最新

  • dongshao8471 2011-10-21 21:39
    关注

    Hmmm, ok:

    As long as your rewrite rule doesn't actually redirect the page (but just rewrites the path internally), your POST data is preserved because it's still using the same HTTP request. Also pages/lease.php doesn't match to the rule ^(lease)$ anyways...

    Although I don't really know which part answered your question. I'm assuming it was the form's action.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试