【发布时间】:2014-10-08 04:56:25
【问题描述】:
我使用 Ubuntu 和 nginx 1.6.2。我无法运行 Phalcon 应用程序,因为它使用 mod_rewrite 规则,但在手册中我找不到 nginx 规则,只有 Apache。这是我的配置:
server {
listen 80;
server_name invo;
index index.php index.html index.htm;
set $root_path '/home/me/invo/public';
root $root_path;
location / {
try_files $uri $uri/ /index.php;
# These rules doesn't work
rewrite ^/$ /public/ break;
rewrite ^(.*)$ /public/$1 break;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?_url=/$1 break;
}
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
我评论了三个对我不起作用的规则。我一直打开 http: //invo/cat/index http: //invo/something 我总是看到主页。
这是 Apache 的 Phalcon 规则:
# /invo/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
# /invo/public/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
【问题讨论】:
标签: mod-rewrite nginx phalcon