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

Gop*_*mal 7 php forms .htaccess wamp

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

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

index.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>
Run Code Online (Sandbox Code Playgroud)

当用户输入并提交详细信息时.它重定向到下一页,url包含查询字符串,如,

http://localhost/info?username=john&company=zend&email=beast@example.com
Run Code Online (Sandbox Code Playgroud)

我想像这样显示上面的网址,

http://localhost/info/john/zend/beast@example.com
Run Code Online (Sandbox Code Playgroud)

并使用url从url获取值 $_GET['username'],$_GET['company'] and $_GET['email']

我尝试了很多重写规则,包括下面的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]
Run Code Online (Sandbox Code Playgroud)

但没有任何作用.

我试过这个清理搜索查询的URL?太.

有人会帮我解决这个问题.

Mon*_*One 1

流程是这样的。

将您的表单提交到route.php

这是route.php的代码

if(isset($_GET['username']) && isset($_GET['company'])  && isset($_GET['email']) )
    $url = '/info/'.$_GET['username'].'/'.$_GET['company'].'/'.$_GET['email']
header('Location: '.$url);
Run Code Online (Sandbox Code Playgroud)

在你的 .htaccess 中

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