Reputation: 23
I am trying to set up ngnix with a PhalconPHP framework tutorial which they have provided a structure of:
tutorial/.htaccess:
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
tutorial/public/.htaccess:
AddDefaultCharset UTF-8
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
Another folder is app
which contains the folders: controllers
, models
and views
. Now this tutorial runs perfectly on apache but on nginx , I have tried different rules which are not working. Basic config of my ngnix is:
server config:
server {
listen 80;
server_name localhost;
root C:/nginx/html;
location /tutorial {
rewrite ^/tutorial/(.*)$ /tutorial/public/$1 break;
try_files $uri $uri/ /tutorial/public/index.php?q=$uri&$args;
}
location /tutorial {
root C:/nginx/html;
index index.php;
rewrite ^/tutorial/(/.*)$ /public$1 break;
try_files $uri $uri/ /tutorial/public/index.php?$args;
}
}
Can anyone please help me in setting up the location rules for this tutorial on nginx.I even converted those .htaccess rules into nginx rules online, but I don't know where I am wrong.
Upvotes: 1
Views: 1794
Reputation: 761
It seems you are using Windows
within nginx & want to use phalcon
So you can install PHP - FastCGI on Windows
Then using main PhalconPHP nginx config that included in docs here.
It might be like this:
server {
listen 80;
server_name localhost;
index index.php index.html index.htm;
root C:/nginx/html/tutorial/public;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^(.*)$ /index.php?_url=$1;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9123;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root C:/nginx/html/tutorial/public;
}
location ~ /\.ht {
deny all;
}
}
Try above config.
Upvotes: 1