你好我正在使用这个.htaccess代码来重定向网址。
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>
所以我希望这个动作是/ printer / 123,但我得到/ printer /?= 123
答案 0 :(得分: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();
}
?>
使用此技巧