0
我使用Ubuntu和nginx 1.6.2。我無法運行Phalcon應用程序,因爲它使用mod_rewrite規則,但在手冊中我找不到nginx規則,只能使用Apache。這裏是我的配置:無法使用Phalcon應用程序運行mod_rewrite
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/indexhttp:// invo/something我總是看到主頁面。
這裏的爾康規則阿帕奇:
# /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>