如何在表单GET方法中创建自定义URL [英] How Create a custom URL in form GET method

查看:84
本文介绍了如何在表单GET方法中创建自定义URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的html页面中有一个表单,如下所示

I have a form in my html page, as below

<form method="get" action="example.php" name="find">
<input type="text" name="productname" />
<input type="submit" value="find product" name="getproduct" />
</form>



当我按下提交按钮时,它会将类似URL的内容发送到example.php页面



When I press the submit button it sends such like URL to example.php page

http://www.example.com/example.php?productname=product



我想获得如下网址



I want to get this URL as below

http://www.example.com/example/product



注意:我需要这种URL,因为我需要使用.htaccess重写URL.
请指导我,我该怎么做.



Note: I want this kind of URL because I need to Rewrite the URL using .htaccess.
Please guide me, how can i do that.

推荐答案

您可以使用HTML表单中的隐藏字段来存储原始URL或使用以下内容:
You could use a hidden field in HTML form to store your original URL or use the following:


uri =


_SERVER [' REQUEST_URI'];
_SERVER['REQUEST_URI'];


这篇关于如何在表单GET方法中创建自定义URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆