我正在尝试用PhalconPHP框架教程来设置ngnix,它们提供了如下结构:
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]另一个文件夹是app,它包含文件夹:controllers、models和views。现在,本教程在apache上运行得很好,但是在nginx上,我尝试了不同的规则,这些规则不起作用。我的ngnix的基本配置是:
服务器配置:
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;
}
}有人能帮我在nginx上设置本教程的位置规则吗?我甚至在网上把.htaccess规则转换成nginx规则,但我不知道我错了什么地方。
发布于 2015-10-28 08:15:09
似乎您在nginx中使用Windows &想要使用phalcon
因此,您可以安装PHP - FastCGI on Windows,然后使用docs 这里中包含的主PhalconPHP nginx。
可能是这样的:
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;
}
}尝试上面的配置。
https://stackoverflow.com/questions/33382268
复制相似问题