T
T
try4tune2013-05-23 18:42:18
Nginx
try4tune, 2013-05-23 18:42:18

Correct nginx rewrite in subfolders with the same projects. How?

Help, I've been fighting for half a day, but so far nothing.
There is a main nginx host, and there are a bunch of folders in it, each of which has a copy of the project installed. The project requires a rewrite, for example test.domain.com/project1/login/ should work fine.
The current config is:

server {
    listen 80 default_server;
    server_name _; 
    server_name_in_redirect off;
    root  /usr/share/nginx/default;
}

server {
        listen   80; ## listen for ipv4; this line is default and implied

        root /usr/share/nginx/www;
        index index.php index.html index.htm;

        server_name test.domain.com;

        location / {
                try_files $uri $uri/ @handler;
                expires 30d;
        }

        ## These locations would be hidden by .htaccess normally
        location ~* ^/.*/lib/                { deny all; }
        location ~* ^/.*/cache/          { deny all; }

        location /. {
            return 404;
        }

        location @handler {
            rewrite / /index.php;
        }

        location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
            rewrite ^(.*.php)/ $1 last;
        }

        location ~* \.php$ {
                if (!-e $request_filename) { rewrite / /index.php last; } 
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/tmp/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        location ~ /\.ht {
                deny all;
        }
}

How to make rewrites work for subfolders? Now it gives 500 error.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Sheleg, 2013-05-24
@Duti_Fruti

Check if it gives 500 if test.domain.com/project1/login/index.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question