Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
.htaccess 强制重写规则使用上一个重写规则的结果_.htaccess_Zend Framework_Mod Rewrite - Fatal编程技术网

.htaccess 强制重写规则使用上一个重写规则的结果

.htaccess 强制重写规则使用上一个重写规则的结果,.htaccess,zend-framework,mod-rewrite,.htaccess,Zend Framework,Mod Rewrite,我正在寻找一种方法,强制.htaccess文件中的重写规则使用以前的重写规则的结果 我有以下规则: RewriteRule ^this-controller/this-action.*$ /that-controller/that-action 这可以很好地工作,但是我使用的是Zend Framework,它需要额外的规则来将所有请求路由到index.php进行处理 RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FI

我正在寻找一种方法,强制.htaccess文件中的重写规则使用以前的重写规则的结果

我有以下规则:

RewriteRule ^this-controller/this-action.*$ /that-controller/that-action
这可以很好地工作,但是我使用的是Zend Framework,它需要额外的规则来将所有请求路由到index.php进行处理

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !server-status
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
结果是以下错误:

'Invalid controller specified (this-controller)'

它似乎正在使用原始url将请求重定向到index.php(
此控制器/此操作
)。如何让它将重写url(
/该控制器/该操作
)传递到index.php?

您最好使用ZF路由处理此问题,或者使用用户可以看到的重定向?使用路由-此控制器/此操作,使用重定向,他们会看到其他Apache规则应根据以前规则的结果进行操作,因此,如果您的第一个规则是匹配的,那么后续规则应该获取该控制器而不是该控制器(假设它也是匹配的)。你能确认第一条规则实际上是匹配的吗?我建议暂时将结果设置为重定向,以便您可以在浏览器中看到结果。同时设置
[L]
标志,这样规则处理将停止,您可以确定index.php没有得到它。Zend正在检查原始url,而不是重写的url。所有url都重写为index.php,因此Zend了解请求的url的唯一方法是查看原始url。唯一的解决方案是修改Zend,或者通过添加
[P]
标志来代理请求。我不知道zend,所以我不能帮你做第一个选择。