dongzhang5006
2016-02-09 16:11
浏览 154
已采纳

使用.htaccess重写路径变量

I'm creating which needs to communicate with some PC software. When PC software call script int needs to include Username and Relative Path to file on server that PHP need to read.

This is PHP in get.php:

$Username = $_GET['Username'];
$RelativePath = $_GET['Path'];

Non rewrited URL looks like this:

http://localhost/get.php?Username=C8WgtdmAytNhGcq&Path=folder/Test.txt

Now I want to rewrite it to:

http://localhost/get/C8WgtdmAytNhGcq/folder/Test.txt

But I have problem because Path contains slash.

How I can rewrite it with more than one folder in path?

图片转代码服务由CSDN问答提供 功能建议

我正在创建哪些需要与某些PC软件通信。 当PC软件调用脚本int需要在PHP需要读取的服务器上包含文件的用户名和相对路径时。

这是 get.php 中的PHP:< / p>

  $ Username = $ _GET ['Username']; 
 $ RelativePath = $ _GET ['Path']; 
   
 \  n 

未重写的URL如下所示:

http://localhost/get.php?Username = C8WgtdmAytNhGcq&amp; Path = folder / Test.txt < p>现在我要将其重写为:

http://localhost/get/C8WgtdmAytNhGcq/folder/Test.txt

但我有问题,因为Path包含斜杠。

如何在路径中使用多个文件夹重写它?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新