2011-05-21 40 views
0

你好,我使用這個.htaccess代碼來重定向網址。從選擇表單中刪除?=查詢。 (用於mod_rewrite)

RewriteEngine on 
RewriteRule ^printer/([^/\.]+)/?$ printer.php?id=$1 [L] 

所以任何product.php?id = 123將成爲/ product/123。

我改變了所有的鏈接,但我有一個html選擇形式的問題,無論我做什麼,我不能擺脫'?='標誌?我怎麼能擺脫他們..?

這裏是html代碼:

   <form action="/printer/" method="get" accept-charset="utf-8"> 
        <select name="" id="printers"> 

         <?php foreach($printers as $printer): ?> 
          <option class="printer_model" id="#<?php echo $printer['printer_model'] ?>" 
          value="<?php echo $printer['printer_id']; ?>"> 
           <?php echo $printer['printer_model']?> 
          </option> 
         <?php endforeach;?> 
        </select> 

,所以我希望動作要/打印機/ 123,但我得到/打印機/ = 123

+0

擺脫他們從哪裏? – BoltClock 2011-05-21 19:53:32

+0

重寫規則似乎是從你理解它的方式起作用的。 '^ product /([^/\.]+)/?$'不符合「/product.php?id=123」 – 2011-05-21 19:54:49

+0

使用此代碼我得到/ printer /?= 123而不是/ printer/123 – Pinokyo 2011-05-21 19:54:55

回答

0

HTML:

<form action="/printers.php" method="post" accept-charset="utf-8"> 
    <select name="printers" id="printers"> 

     <?php foreach($printers as $printer): ?> 
      <option class="printer_model" id="#<?php echo $printer['printer_model'] ?>" 
      value="<?php echo $printer['printer_id']; ?>"> 
        <?php echo $printer['printer_model']?> 
      </option> 
     <?php endforeach;?> 
    </select> 

printers.php:

<?PHP 
if(isset($_POST['printers'])) 
{ 
    header('location: /printer/' . $_POST['printers'] . '/'); 
    exit(); 
} 
?> 

我們電子從這個把戲