如何改造这个nginx的配置阿帕奇try_files模拟
location/{
try_files /public/$uri @app;
}
location @app {
fastcgi_pass php5-fpm;
}
}
到Apache的配置?
如何改造这个nginx的配置阿帕奇try_files模拟
location/{
try_files /public/$uri @app;
}
location @app {
fastcgi_pass php5-fpm;
}
}
到Apache的配置?
这是你可以使用(需要一定的调整我猜):
Alias /public /xxxxx/public
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond /xxxxx/public/%{REQUEST_URI} !-f
RewriteCond /xxxxx/public/%{REQUEST_URI} !-d
RewriteRule . "-" [H=application/x-httpd-php]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule (.) /public/$1 [L,QSA]
的application/x-httpd-php
是PHP处理程序,它可以在你的设置(fcgid脚本/应用/ PHP的不同... )检查你的php安装程序定义的处理程序。
这实际上只是做了两件事。
所以在Apache的,我们需要做测试第一
RewriteCond %{DOCUMENT_ROOT}/public/%{REQUEST_URI} -f
RewriteRule (.*) /public/$1 [L]
的RewriteCond提出以下规则的条件,-f意味着该文件存在。所以我们知道该文件存在于公共子目录中,所以应用将请求重写到公共子目录的规则。 L标志意味着Apache将认为这是最后一个重写规则,并且不处理任何其他重写规则。
现在为第二部分。
RewriteRule . "-" [H=application/x-httpd-php]
当然,这个假设所有相应的Apache模块安装和积极的,特别是mod_rewrite的和RewriteEngine on
已经被调用。值得一提的是,在nginx和apache中都有很多选项必须设置才能正常工作。
更多文档浏览:http://httpd.apache.org/docs/current/mod/mod_rewrite.html
这是一个有趣的问题,因为在/公众甚至PHP文件将返回明文和位置上的过滤/公众不能因为使用。如果文件不存在,它会仍然传递给PHP。 – pucky124