2012-07-14 21 views
0

我有一个形式的网页,有3个参数,如URL重写与形式和3个参数

http://www.likeforex.com/currency-converter/fxconverter.php?f=euro-eur&t=usd-us-dollar&amt=1

我用的.htaccess页面改写为:f_t.htm/amt为:

http://www.likeforex.com/currency-converter/euro-eur_usd-us-dollar.htm/1

但是,我的问题是当用户更改amt(页面中间)的值时,表单被重新组合,并且重新组合的页面仍然是参数格式。如何在重写格式后制作网址?

提交按钮或其他任何错误?

the form: 
<form name="e" method="get" action="fxconverter.php"> 
the amt parameter: 
<input type="text" id="amt" name="amt" size="16" maxlength="16" value="'.$amt.'" onclick="this.focus();this.select();" />' 
the submit button: 
<input type="submit" value="Convert" class="bt" /> 
the .htaccess line: 
RewriteRule ^(.*)_([^_]+)\.htm/([^/]+)$ fxconverter.php?f=$1&t=$2&amt=$3 [NC] 

非常感谢。

+1

你能告诉我们表格和相关的mod_rewrite,否则它是一个猜谜游戏...... – 2012-07-14 16:18:06

+0

没什么。只有RewriteRule ^(。*)_([^ _] +).htm /([^ /] +)$ fxconverter.php?f = $ 1&t = $ 2&amt = $ 3 [NC] – 2012-07-14 16:22:50

+0

@ likeforex.com请更新你的问题。 – Gumbo 2012-07-14 16:26:42

回答

1

你不能使用的一种形式,无论POST/GET并期望参数输出就像一个网址如http://www.likeforex.com/currency-converter/euro-eur_usd-us-dollar.htm/1

你需要待办事项什么是稍微改变形式和使用JavaScript来构建URL,然后重定向。

<script> 
function goForm(form){ 
    f = form.elements["f"].value; 
    t = form.elements["t"].value; 
    amt = form.elements["amt"].value; 

    window.location.href = 'http://www.likeforex.com/currency-converter/'+f+'_'+t+'.htm/'+amt; 
} 
</script> 

<form name="currencyForm" method="GET" action=""> 
<input id="f" name="f" value="euro-eur" type="hidden"> 
<input id="t" name="t" value="usd-us-dollar" type="hidden"> 
<input id="amt" name="amt" size="16" maxlength="16" value="1" onclick="this.focus();this.select();" type="text"> 
<input type="button" name="button" value="Click" onClick="goForm(this.form)"> 
</form> 

然后你可以利用mod_rewrite。

我个人会弃GET(对于花哨的url),只是使用POST。搜索引擎不会查询你的表单,所以在使用GET时没有任何优势,因为它可以让那些想要抓取你的内容来消化其工作的人更容易。还记得任何没有启用JavaScript的人将无法使用我的解决方案的形式。

+0

非常感谢。没有其他解决方案没有JS? – 2012-07-14 17:22:49