サブディレクトリで nginx を CakePHP と連携させるのに非常に苦労しています。
私は Apache しか知らず、何か新しいことを学びたいので、nginx を使用しています。私の目標は、サブディレクトリで CakePHP をホストすることです。
/etc/nginx/sites-available/default ファイルは次のようになります。
server {
listen 0.0.0.0:80;
root /var/www/;
index index.html index.php;
include /etc/nginx/include/php;
error_page 404 = /404.html;
location / {
root index.html;
index index.php index.html index.htm;
autoindex on;
try_files $uri $uri/ /index.php;
}
location /randodb {
if (!-e $request_filename) {
rewrite ^/randodb(.+)$ /randodb/app/webroot/$1 last;
break;
}
}
location /randodb/app/webroot {
if (!-e $request_filename) {
rewrite ^/randodb/app/webroot/(.+)$ /randodb/app/webroot/index.php?url=$1 last;
break;
}
}
}
server {
listen 0.0.0.0:443;
root /var/www/;
index index.html index.php;
fastcgi_param HTTPS on;
include /etc/nginx/include/ssl;
include /etc/nginx/include/php;
error_page 404 = /404.html;
}
私が何をしても、/randodb フォルダー内のすべての要求は 301 リダイレクトを受け取ります。
それはいつも私をリダイレクトしますhttp://nginx-php-fastcgi/randodb/
この動作を確認したい場合: http://www.matgilbert.com/randodb