为什么我的最后一个规则[L]不阿帕奇工作吗? [英] Why is my LAST rule [L] not working in apache?

查看:159
本文介绍了为什么我的最后一个规则[L]不阿帕奇工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景,我运行Zend框架应用程序。要挤最具表现出它越好。所以我想移动的规则出来的.htaccess究竟由Zend框架书的作者根据此博客帖子信:的http://www.armando.ws/2009/03/how-to-run-zend-framework-with-no-htaccess-file/

Background, I'm running a Zend Framework application. Trying to squeeze the most performance out of it as possible. So I'm trying to move the rules out of .htaccess exactly to the letter per this blog post by the author of a Zend Framework book: http://www.armando.ws/2009/03/how-to-run-zend-framework-with-no-htaccess-file/

因此​​,基本上,在httpd.conf中,我加入了包括到conf /额外/的httpd-zf.conf它包含在我的.htaccess文件,可以正常使用了同样的事情。

So basically, in httpd.conf, I'm adding an include to conf/extra/httpd-zf.conf which contains the same thing that was in my .htaccess file and working perfectly.

下面是相关的code,不正确的的httpd-zf.conf功能:

Here's the pertinent code that doesn't function right in httpd-zf.conf:

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

控制器正常工作。在index.php看到。但静态文件不起作用。它的错误了说,这是不是一个有效的控制,那么清楚它正在通过index.php文件运行。

Controllers work fine. The index.php is seen. But static files don't work. It errors out saying that it isn't a valid controller, so clearly it's being run through index.php.

这是几乎一样,如果运行后:

It's almost as if after running:

RewriteRule ^.*$ - [L,NC]

它保持正常持续。而在事实上,删除这一行:

it keeps right on going. And in point of fact, Removing this line:

RewriteRule ^.*$ /index.php [NC,L]

修复了静态文件,当然,打破它的其余部分。

fixes the static files, but of course breaks the rest of it.

所以基本上最后的规则不工作似乎。

So basically the LAST rule is not working it seems.

在得到这个正常工作任何想法?

Any ideas on getting this to work correctly?

感谢您。

更新

打开日志记录(我不得不加息它为LogLevel 9)后,事实证明,即使去除
    重写规则^ * $的index.php [NC,L]
允许静态文件来解决,这不是条件的RewriteCond%{} REQUEST_FILENAME匹配-s不管是什么...它只是没有通过反正这使得文件显示...

After turning on logging (I had to hike it up to Loglevel 9), it turned out that even though removing RewriteRule ^.*$ /index.php [NC,L] allowed static files to resolve, it was NOT matching on condition RewriteCond %{REQUEST_FILENAME} -s no matter what...it just did "pass through" anyway which allowed the file to show...

那么清楚,但事实上,是的.htaccess正确的路径上进行它的工作,其中的httpd-zf.conf有错误的路径....必须有一个点的地方,我可以告诉大家的httpd-zf.conf什么我的文档根目录路径为...

so clearly, the fact that .htaccess was on the correct path made it work where the httpd-zf.conf has the wrong path.... There must be a spot somewhere that I can tell httpd-zf.conf what my docroot path is...

推荐答案

找到了解决办法!

这里的code的作品:

Here's the code that works:

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -s [OR]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -l [OR]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -d

本维基文章解释为什么它不工作:
http://wiki.apache.org/httpd/RewriteContext

This wiki post explains why it wasn't working: http://wiki.apache.org/httpd/RewriteContext

这篇关于为什么我的最后一个规则[L]不阿帕奇工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆