Php 使用.htaccess绕过Zend Framework并在子目录中运行不同的Framework

Php 使用.htaccess绕过Zend Framework并在子目录中运行不同的Framework,php,.htaccess,zend-framework,mod-rewrite,Php,.htaccess,Zend Framework,Mod Rewrite,我试图在Zend站点的子目录中运行一个非Zend php应用程序。对于.htaccess子目录“/branchs”中的所有文件,我想绕过Zend应用程序。到目前为止,我发现的解决方案都没有奏效。以下是当前的.htaccess文件: RewriteEngine on RewriteBase / # WWW Resolve RewriteCond %{HTTP_HOST} ^domain\.com$ [NC] RewriteRule ^web/content/(.*)$ http://www.do

我试图在Zend站点的子目录中运行一个非Zend php应用程序。对于.htaccess子目录“/branchs”中的所有文件,我想绕过Zend应用程序。到目前为止,我发现的解决方案都没有奏效。以下是当前的.htaccess文件:

RewriteEngine on
RewriteBase /

# WWW Resolve
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^web/content/(.*)$ http://www.domain.com/$1 [R=301,L]

# Eliminate Trailing Slash
RewriteRule web/content/(.+)/$ http://www.domain.com/$1 [R=301,L]

# Route Requests
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
这能在.htaccess中实现吗?

您目前拥有:

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
这是没有意义的,因为您指定的“重写条件”基本上不会对实际文件、目录和符号链接执行任何操作,它将永远无法工作。这是因为,RewriteRule后面紧跟着将所有内容重写为index.php的规则

如果您的目的是将不是请求的所有内容都指向index.php文件的真实目录,那么您应该有如下内容:

RewriteCond %{REQUEST_FILENAME} -s
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} !^branches/
RewriteRule ^.*$ index.php [NC,L]
要添加忽略分支的特殊情况,只需添加如下条件:

RewriteCond %{REQUEST_FILENAME} -s
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} !^branches/
RewriteRule ^.*$ index.php [NC,L]

我可以在不更改.htaccess的情况下解决这个问题,而只是将我的子目录放在“/content”中。

我在这里没有看到任何东西表明您尝试了与/branchs相关的任何重写规则。您能告诉我们您尝试了哪些不起作用的内容吗?您是在寻找这些请求的直接传递,还是它们需要自己的重写逻辑?我希望直接传递'/branchs'中的任何内容。我尝试了以下操作:
RewriteRule!(branchs)$index.php-[NC,L]
重写规则^branchs/$branchs/index.php[L,QSA]
重写规则^blog-[NC,L]
以及其他许多变体。这实际上是默认的Zend.htaccess。应用这些更改会破坏Zend应用程序,[NC,L]意味着重写规则不执行任何其他规则,因此Ryan的原始htaccess确实有效。