-1

I'm trying to run a CakePHP app from within a subfolder on Nginx, but the static files are not being found and are instead being passed to the app controller. Here's my current config:

    location /uniquetv {
        index index.php index.html;

        if (-f $request_filename) {
            break;
        }

        if (!-e $request_filename) {
            rewrite ^/uniquetv(.+)$ /uniquetv/webroot/$1 last;
            break;
        }
    }                                        

    location /uniquetv/webroot {
        index index.php;

        if (!-e $request_filename) {
            rewrite ^/uniquetv/webroot/(.+)$ /uniquetv/webroot/index.php?url=$1 last;
            break;
        }
    }

Any ideas? :)

robotmay
  • 115
  • 1
  • 5

1 Answers1

0

Throlkim, what exactly is being displayed when you browse to the url you want to use? ie are you getting a 504 error message etc

you need to have something similar to this which works for me

server {

    listen   80;
    server_name  yourwebsite.com;

    access_log /path_to_your_logfile/log/access.log;
    error_log /path_to_your_logfile/log/error.log;

    location / {

        root /path_to_cake_root/cake/app/webroot;
        index index.php;

        if (-f $request_filename) {
            break;
        }
        if (!-f $request_filename) {
            rewrite ^/(.+)$ /index.php?url=$1 last;
            break;
        }

        #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ .php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME /path_to_cake_root/cake/app/webroot/index.php;
            #$fastcgi_script_name;
            include        /etc/nginx/fastcgi_params;
        }
    }
}

I asked a similar question which was resolved as per accepted answer and a bit of tweeking cakephp & nginx config/rewrite rules

seanl
  • 470
  • 5
  • 13