Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何使用htaccess代码重定向URL两次_.htaccess - Fatal编程技术网

.htaccess 如何使用htaccess代码重定向URL两次

.htaccess 如何使用htaccess代码重定向URL两次,.htaccess,.htaccess,我对htaccess代码有问题 假设我有一个这样的html文件 Name: <input type="text" name="fname"> Age: <input type="text" name="age"> <input type="submit"> 它将显示在地址localhost/Juriaan/26中 现在,我想将其转换回:localhost/welcome.php?fname=Juriaan&age=26,以便在欢迎页面中获取$\u get数据

我对htaccess代码有问题

假设我有一个这样的html文件

Name: <input type="text" name="fname">
Age: <input type="text" name="age">
<input type="submit">
它将显示在地址localhost/Juriaan/26中

现在,我想将其转换回:localhost/welcome.php?fname=Juriaan&age=26,以便在欢迎页面中获取$\u get数据

RewriteRule ^([a-zA-Z_]+)/([0-9]+)$ welcome.php?fname=$1&age=$2
但是,它失败并抛出错误。
你能帮我一下吗?

第二次转换不应该是htaccess代码。Htaccess没有与PHP的连接,因此您将进入一个无限循环。相反,使用PHP代码解析当前URL以交换回数据
$\u SERVER['PHP\u SELF']
应该为您获取
Juriaan/26
,然后您可以将其解析回并设置为
$\u get
数组。它始终显示错误未找到此服务器上未找到请求的URL/Juriaan/26。那我们怎么做呢。我们无法创建文件夹Jurrian/26并将php页面放入其中
RewriteRule ^([a-zA-Z_]+)/([0-9]+)$ welcome.php?fname=$1&age=$2