Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.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/8/.htaccess/5.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
PHP GET变量包含正向斜杠重写_Php_.htaccess - Fatal编程技术网

PHP GET变量包含正向斜杠重写

PHP GET变量包含正向斜杠重写,php,.htaccess,Php,.htaccess,我正在努力实现以下目标: 重写: http://url.com?subfolder=folderone/foldertwo/folderthree 致: 并在PHP中调用$\u GET['subfolder'],它应该检索folderone/foldertwo/folderthree 当定义?子文件夹=时,它会按预期工作,但当它尝试查找具有该路径的文件夹时,以下情况不起作用: RewriteEngine on RewriteRule ^subfolder/([^/.]+)/?$ index.p

我正在努力实现以下目标:

重写:

http://url.com?subfolder=folderone/foldertwo/folderthree
致:

并在PHP中调用
$\u GET['subfolder']
,它应该检索
folderone/foldertwo/folderthree

当定义
?子文件夹=
时,它会按预期工作,但当它尝试查找具有该路径的文件夹时,以下情况不起作用:

RewriteEngine on
RewriteRule ^subfolder/([^/.]+)/?$ index.php?subfolder=$1 [L]
上述情况是否可能

谢谢

使用这个:

RewriteEngine on
RewriteRule ^subfolder/(.*)$ index.php?subfolder=$1 [L]
使用这个:

RewriteEngine on
RewriteRule ^subfolder/(.*)$ index.php?subfolder=$1 [L]

在第一个URL中,“folderone/foldertwo/folderthree”部分不被视为参数“subfolder”的值,因为这将违反编码。这是你自己创建的URL吗?然后您应该修复它,而不是试图解决前面介绍的问题。它只是一个将被导航到的URL,但仍然保留在
index.php
本身。我正在尝试将其作为模板来导航到用户主文件夹的子文件夹。有点像Dropbox,当你点击一个名为“Images”的文件夹时,它会导航到
https://www.dropbox.com/home/images
并输入该文件夹。当您在“图像”的子文件夹中导航时,文件夹名称将仅附加到URL。有解决办法吗?这不是我问题的答案。我将以另一种方式尝试:您必须对该路径进行编码,才能在url get参数中使用它。看看
urlencode()
:哦,如果你的意思是,如果URL可以动态创建,那么是的,它将是锚href中的一个链接。我尝试了
,一切正常,直到我删除
?子文件夹=
,这样URL被重写,但随后它再次查找
/new/next/now
,在第一个URL中,“folderone/foldertwo/folderthree”部分不被视为参数“subfolder”的值,因为这会违反编码。这是你自己创建的URL吗?然后您应该修复它,而不是试图解决前面介绍的问题。它只是一个将被导航到的URL,但仍然保留在
index.php
本身。我正在尝试将其作为模板来导航到用户主文件夹的子文件夹。有点像Dropbox,当你点击一个名为“Images”的文件夹时,它会导航到
https://www.dropbox.com/home/images
并输入该文件夹。当您在“图像”的子文件夹中导航时,文件夹名称将仅附加到URL。有解决办法吗?这不是我问题的答案。我将以另一种方式尝试:您必须对该路径进行编码,才能在url get参数中使用它。看看
urlencode()
:哦,如果你的意思是,如果URL可以动态创建,那么是的,它将是锚href中的一个链接。我尝试了
,一切正常,直到我删除
?子文件夹=
,URL被重写,但它再次查找
/new/next/now