サブディレクトリに設置したfuelphpにアクセスできるようにNginxを設定する

http://example.com/subdirにアクセスした時に、/var/www/html/subdirに設置したfuelphpを動かせるようにしたいと思った時のメモ。

   server {
       listen       80 default_server;
       access_log   /var/log/nginx/development.access.log;
       index     index.php index.html;

       # main
       location / {
            root      /var/www/html/;
            try_files $uri $uri/ /index.php;
       }

       # sub
       location ^~ /subdir {
            alias     /var/www/html/subdir/public;
            try_files $uri $uri/ /index.php;

            if (!-e $request_filename) { rewrite ^ /subdir/index.php last; }

            location ~ \.php$ {
                if (!-f $request_filename) { return 404; }
                fastcgi_pass 127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $request_filename;
            }
        }
   }
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.