.htaccessredirect所有子目录和文件

我们有一个子网站domain.com/path/ad,我想直接将所有的stream量直接传递给框架处理程序。 domain.com/path/index.cfm

到目前为止,我有

RewriteRule ^$ index.cfm [QSA,NS] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.cfm [R=permanent,L] 

如果文件夹存在,它会正确地将/ path / ad / otherredirect到/path/ad/index.cfm。 我需要什么使它适用于不存在的文件夹? 我还需要跟踪请求的原始文件/path。

 /path/ad/example1 => /path/ad/index.cfm?ad=example1 

/path下的.htaccess

 <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^path/ad/(.+)$ path/index.cfm?ad=$1 [R=permanent,L] </IfModule> 

在你的问题的开始,你写道你想redirect到path/index.cfm ,而最后你写道path/ad/index.cfm我假设你打算前者。

一种方法是添加一个index.xxx(例如,如果您使用php的index.php)脚本。 如果尝试访问/ path / ad / example1并且/ ad / example1部分不存在(假设服务器configuration为使用索引),Apache将在环境variables中使用/ ad / example1运行/path/index.php。 xxx为索引,无论是全球或从.htaccess)。

由于这是一个脚本,可以做各种redirect。

这不是最好的解决scheme,因为你必须保持两个位置的redirect,但如果你没有find另一种方式,那么你可以试试看。