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 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?