如何重新制作此nginx配置
location / {
try_files /public/$uri @app;
}
location @app {
fastcgi_pass php5-fpm;
}
}
到Apache配置?
答案 0 :(得分:1)
这实际上只是做了两件事。
所以在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
答案 1 :(得分:0)
这是你可以使用的东西(我猜需要一些调整):
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-script / application / php ...)检查你的php设置定义的处理程序。