如何在php的表单提交获取方法中将查询字符串转换为url slug?

如何在php的表单提交获取方法中将查询字符串转换为url slug?,php,forms,.htaccess,wamp,Php,Forms,.htaccess,Wamp,我正在用php开发一个网站,这是我第一个使用php的网站,我是php新手 该网站包含两个页面,index.php和info.php php的格式如下: <form action="info.php" method="get"> <input type="text" name="username" /> <input type="text" name="company" /> <input type="email" name="em

我正在用php开发一个网站,这是我第一个使用php的网站,我是php新手

该网站包含两个页面,index.php和info.php

php的格式如下:

<form action="info.php" method="get">
    <input type="text" name="username" />
    <input type="text" name="company" />
    <input type="email" name="email" />
    <button type="submit">Click to Proceed!</button>
</form>
我想像这样显示上面的url

http://localhost/info/john/zend/beast@example.com
使用
$\u get['username']、$\u get['company']和$\u get['email']从url获取值

我尝试了很多重写规则,包括htaccess中的以下规则

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^([\d\w-]+)$ info?username=$1&company=$2&email=$3 [L,QSA]
RewriteRule ^([\d\w-]+)$ info?username=$1&company=$2&email=$3 [QSA]
RewriteRule ^(.*)$ info?username=$1&company=$2&email=$3 [L,QSA]
RewriteRule ^([a-zA-Z0-9-/]+)/([0-9]+)$ info?username=$1&company=$2&email=$3 [L,QSA]
RewriteRule ^([a-zA-Z0-9-/]+)/([0-9]+)$ info?username=$1&company=$2&email=$3 [QSA]
但什么都不管用

我也试过了


有人能帮我解决这个问题吗。

用一个简单的规则检查一下重写是否有效。确保已启用“重写”模块

 RewriteRule  ^info/(.+)/(.+)/(.+)(/*)$ info?username=$1&company=$2&email=$3 [L,QSA]
流程是这样的

将表单提交到route.php

if(isset($_GET['username']) && isset($_GET['company'])  && isset($_GET['email']) )
    $url = '/info/'.$_GET['username'].'/'.$_GET['company'].'/'.$_GET['email']
header('Location: '.$url);
下面是route.php的代码

if(isset($_GET['username']) && isset($_GET['company'])  && isset($_GET['email']) )
    $url = '/info/'.$_GET['username'].'/'.$_GET['company'].'/'.$_GET['email']
header('Location: '.$url);
在您的.htaccess中

RewriteRule  ^info/(.+)/(.+)/(.+)$ info.php?username=$1&company=$2&email=$3 [L,QSA]

这与我们想要的正好相反。你不能在服务器端真正改变这一点,你必须使用JavaScript。如果你想要干净的URL,你应该使用POST而不是GET。我不想要干净的URL可能重复。我需要在下一页通过url只这些值。这就是为什么我要用GET@GeraldSchneider你是说这是不可能的。但许多人都同意并认为它正在发挥作用,请参考我提供的链接(最近编辑)。你想要的是路由,它已经在许多框架中实现了。只要选一个,看看它是如何工作的。以Laravel4为例,看看这篇文章是否完全涵盖了你想要的内容:谢谢你的回答。它确实重定向到/info/myname/mycompany/myemail,但它导致在该服务器上找不到/info/myname/mycompany/myemail.php。