mod重写两个单独的文件夹

时间:2013-03-06 19:40:42

标签: apache mod-rewrite

我有一个脚本可以创建一个文件夹的漂亮目录列表。我称它为mydrive。我有两个公共和私人的foders,我有问题用漂亮的网址重新安排人们。

文件放在:/ mydrive / public / folder1 调用:/mydrive/files/mydrive.cgi?path=public/folder1

文件放在:/ mydrive / private / folder1 调用:/mydrive/files/mydrive.cgi?path=private/folder1

我希望它能像这样工作:

网址:www.domain.com/mydrive/folder1 调用:/mydrive/files/mydrive.cgi?path=public/folder1

网址:www.domain.com/mydrive/private/folder1 电话:/mydrive/files/mydrive.cgi?path=private/folder1

我已经尝试了几种配方,但无法让它发挥作用。

1 个答案:

答案 0 :(得分:0)

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^/mydrive/(private/.*)$ /mydrive/files/mydrive.cgi?path=$1 [PT,L]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^/mydrive/(.*)$ /mydrive/files/mydrive.cgi?path=public/$1 [PT,L]
如果将它放在虚拟服务器配置中,

应该可以解决问题。