关于url使用查询字符串和表单操作获取重写

0 php mod-rewrite url-rewriting

请帮助删除其他查询字符串

我在.htaccess中使用此代码

RewriteRule ^ip/(.*)$ /iplookup.php?lookup_ip=$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)

它可以工作,但是当尝试在表单中查找其他IP地址时,
它在地址栏中显示如下内容:

"/ip/?lookup_ip=66.249.66.2"
Run Code Online (Sandbox Code Playgroud)

我的表格是

<form action="/ip/" method="get">
<input type="text" value="{$address}" name="lookup_ip" id="lookup_ip">
<input type="submit" value="IP Lookup"/>
</form>
Run Code Online (Sandbox Code Playgroud)

现在可以隐藏"?lookup_ip ="

我想显示/ip/66.249.66.2

我认为我的问题是形式的?

Hug*_*ing 5

当您提交GET请求表单时,链接将更改为包含参数和值为param=value.默认情况下,您无法更改它.

您可以使用javascript为您执行此操作.

<script type='text/javascript'>
function SubmitForm() {
  var val = document.getElementById('lookup_ip').value;

  //check val for length / valid IP here

  window.location.href='/ip/' + val;
  return false;
}
</script>

<form action="/ip/" method="get" onsubmit='return SubmitForm()'>
<input type="text" value="{$address}" name="lookup_ip" id="lookup_ip">
<input type="submit" value="IP Lookup"/>
</form>
Run Code Online (Sandbox Code Playgroud)