用户每次在我的网站上注册时,我希望他们拥有自己的子目录及其注册的"用户名".每个用户子目录都将具有相同的"index.php"文件,该文件将执行某些操作.
例如:"/ users/username1 /"和"/ users/username2 /"
如果有人想要访问子目录,他们可以简单地访问:"www.example.com/users/username1/"或"www.example.com/users/username2/"
简单而混乱的解决方案是简单地为每个用户创建一个子目录,并在每个目录中放置相同的"index.php"文件.但对我来说,这只会占用我的服务器空间并使我的目录变大.
我想知道是否可以使用.htaccess完成所有这些操作?我可以创建一个"index.php"和一个".htaccess"文件并将它们放在我的"/ users /"目录中吗?我必须放在我的.htaccess文件中的实际代码是什么?
如果您有更好的方法,请告诉我.我使用Apache和PHP作为我的工作环境.
谢谢
我正在使用RecursiveIteratorIterator()来探索当前路径的子文件夹,但是通过这种方式探索了所有的树,而我只想要为文件探索我的fodler的直接childern.我怎么能说RecursiveIteratorIterator()不再进一步停止到当前文件夹的第一个子文件?
在Lauri Lehtinen之后,我试过这个:
$it = new RecursiveDirectoryIterator("$directory");
$it->setMaxDepth(1);
Run Code Online (Sandbox Code Playgroud)
我有PHP 5.2.3,但它告诉我setMaxDepth是未定义的.
致命错误:调用未定义的方法RecursiveDirectoryIterator :: setMaxDepth()
我将有许多子目录,例如./ home/a,/ home/a/file,/ home/a/txt,/ home/b,/ home/b/file,/ home/b/txt等.
子目录是按需创建的.我需要将所有子目录添加到open_basedir.
请告知如何使open_basedir识别顶部路径的所有子目录?
我想将所有子域映射到文件夹.
例如,subdomain.domain.com应显示domain.com/clients/subdmain的内容(透明)
RewriteCond %{HTTP_HOST} ^(.+)\.oomail\.org
RewriteCond %{HTTP_HOST} !^www\.oomail\.org [NC]
RewriteRule ^(.+)$ /var/www/clients/%1/$1
Run Code Online (Sandbox Code Playgroud)
我收到500内部服务器错误.为了检查我附加[R]标志的问题
RewriteRule ^(.+)$ /var/www/clients/%1/$1 [R]
Run Code Online (Sandbox Code Playgroud)
我在地址栏中得到了这个结果
http://q1.oomail.org/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/var/www/clients/q1/always.html
Run Code Online (Sandbox Code Playgroud)
然后我创建了一个details.php文件,该文件转储了$ _GET变量的详细信息.它的内容是
<pre>
<?php
var_dump($_GET);
?>
</pre>
Run Code Online (Sandbox Code Playgroud)
并修改了RewriteRule(注意:我将$ 1和%1发送到details.php,显示其内容)
RewriteRule ^(.+)$ details.php?p=%1&d=$1
Run Code Online (Sandbox Code Playgroud)
打开后http://subdomain.oomail.org/file.html
,我输出了
array(2) {
["p"]=>
string(9) "subdomain"
["d"]=>
string(11) "details.php"
}
Run Code Online (Sandbox Code Playgroud)
其中变量p是正确的(%1的值),这是"子域",但d($ 1值)为details.php其中我期待是file.html我在URL打开.我哪里错了?或者如何将file.html(URI)提取到变量中以进行映射?
我想运行一个每晚删除文件夹内容的作业。该文件夹包含5/6个子文件夹。是否可以从每个子文件夹中删除,但不能删除实际文件夹?还是我必须为每个文件夹运行一个任务?
我有一个文件夹c:\ graphics(root)和一个程序创建子文件夹aa,bm,czx,mjpq,zz(这是一个例子,我有很多子文件夹,长度是变量).在每个子文件夹中,我有26个文件和一个文件夹.例如,aa文件夹有:*aa_000.jpg*,*aa_001.jpg*,...,*aa_023.jpg*; 其他两个文件*aa_360.jpg*,aa.html和一个文件夹,路径完成它的C:\ graphics\aa\aa_360.我需要在子文件夹c:\ graphics\aa\aa_360中移动24个文件*aa_000.jpg*,*aa_001.jpg*,...,*aa_023.jpg*,并且还等于每个子文件夹.其他例子是c:\ graphics\mjpq\mjpq_360应该有mjpq_000.jpg,...,mjpq_023.jpg.
我开始编写脚本,想在子文件夹中移动所有.jpg(25个文件)(后来,我不得不想像提取*xxx_360.jpg*)但不能正常工作:
Get-ChildItem c:\graphics -rec | where-object {$_.extension -match "jpg"} | ForEach-object {$newPath =(Get-Location).toString()+(Get-Location).ToString().SubString(10)+"_360"); Move-Item $_.FullName $newPath}
Run Code Online (Sandbox Code Playgroud)
但找不到Get-Location文件路径.谢谢你的进步.
注意:我找到了解决方案.工作,但我在控制台中发现错误:
Get-ChildItem c:\graphics -rec | where-object {$_.extension -match "jpg" -and (!($_.name -like "*360*"))} | ForEach-Object {$newPath =($_.DirectoryName).toString()+($_.DirectoryName).ToString().SubString(10)+"_360"; Move-Item $_.FullName $newPath}
Run Code Online (Sandbox Code Playgroud)
这是我的第一个powershell脚本;)
我正在执行一个Batch-File,它会删除Server上特定文件夹中的所有内容.它到目前为止工作,但遗憾的是,文件夹名称中包含空格的目录将无法识别.我不知道在脚本中放置引号来克服这个限制.
到目前为止这是脚本,它位于"D:\"的根目录中:
cd Sharedfolder
for /f %%i in ('dir D:\Sharedfolder /B /D') do rd %%i /Q /S
del /F /S /Q *.*
Run Code Online (Sandbox Code Playgroud)
它运行良好,但只要我在"Sharedfolder"中有一个目录,它就不适用于该目录.
directory batch-file shared-directory subdirectory delete-directory
#!/bin/bash
#script to loop through directories to merge files
mydir=/data/
files="/data/*"
for f in $files
do
if[ -d "$f" ]
then
for ff in $f/*
do
echo "Processing $ff"
done
else
echo "Processing $f"
fi
done
Run Code Online (Sandbox Code Playgroud)
我有上面的代码来遍历目录和子目录并列出所有文件.我收到错误:意外令牌附近的语法错误`然后'
我在这做错了什么?
我不能使用自定义子目录的功能.
我在"src"下有一个路径层次结构
A/B
与我的所有目录和go-Files(它是我项目的"根").目录不包含子目录,它工作正常.所以最深的路径是"a/b/c".我有
A/B/C
和
的a/b/d
一些go文件.导入"a/b/d"并从"a/b/c"中的文件调用带有"d.DoSomething()"的函数正常工作.
现在我想要重新组织"a/b/d".我将一些文件从"a/b/d"移动到
的a/b/d/E
和其余的文件
的a/b/d/F
如果尝试使用import-statement导入"a/b/d/e"
进口("a/b/d/e")
来自"/ a/b/c"中的同一个文件,想要调用"e.DoSomething()"(这是"DoSomething-function"文件移动到的地方),我收到错误我称之为"e.DoSomething()":"undefined:e".
在搜索结果时,我无法看到具有更深层路径层次结构的示例.通常不可能使用/ import子目录或者问题是什么?
我使用的go-version:go1.2.2 linux/amd64
感谢您的任何建议
我想下载我的sharepoint列表的所有文件.我用这种方法下载文件:
public void DownloadFilesOfSpecialtys( )
{
using (var clientContext = new ClientContext(url))
{
foreach (var item in ids)
{
int listItemId = int.Parse(item.ToString());
statics.files = int.Parse(ids.Count.ToString());
var list = clientContext.Web.Lists.GetByTitle(listtitle);
var listItem = list.GetItemById(listItemId);
clientContext.Load(list);
clientContext.Load(listItem, i => i.File);
clientContext.ExecuteQuery();
var fileRef = listItem.File.ServerRelativeUrl;
var fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, fileRef);
var fileName = Path.Combine(@path , (string)listItem.File.Name);
using (var fileStream = System.IO.File.Create(fileName))
{
fileInfo.Stream.CopyTo(fileStream);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,子文件夹中的文件没有使用此方法下载.有机会浏览列表中的所有子文件夹并下载所有文件吗?
c# directory sharepoint subdirectory sharepoint-clientobject
subdirectory ×10
directory ×4
php ×3
apache ×2
batch-file ×2
.htaccess ×1
bash ×1
c# ×1
delete-file ×1
file ×1
go ×1
import ×1
linux ×1
mod-rewrite ×1
powershell ×1
sharepoint ×1
subdomain ×1