我的搜索乡村表格有代码:
<form name="form_search" id="form_search" class="form1" method="get" action="country/search"><div class="row">
<div class="col-sm-4 col-md-7">
<label>Select country</label>
<div class="select1_inner">
<div class="form-group">
<select class="select2 select" style="width: 100%" name="q" id="q">
<?php
$sql = "SELECT * FROM country";
$query = $conn->query($sql);
while ($row = $query->fetch_assoc()) :
$country_name=$row['country_name'];
?>
<option value=<?php echo $country_name?>><?php echo $country_name?></option>
<?php endwhile;?>
</select>
</div>
</div>
</div>
在前端url
将显示:http://example.com/country/search?q=参见表
,但我会在后端http://example.com/page.php?module = search&amp;Id1 = $ 1
将url
重定向到真实目录使用.htaccess
RewriteEngine On
Options -Indexes
rewriteRule ^country/search$ page.php?module=search&id1=$1 [L]
但这不起作用,我无法获得值q
参数
请帮助我如何配置此表格
谢谢。
您应该使用 RewriteCond
backeference:
RewriteCond %{QUERY_STRING} q=([^&]*)
RewriteRule ^country/search$ page.php?module=search&id1=%1 [R=301,L]
第1行:测试是否包含q={any_characters}
第2行:如果URL为 country/search
,则重定向到page.php?module=search&id1={any_characters}
永久