Jump to content

Nginx deployment in subdirectory


julienmarie
 Share

Recommended Posts

Hello,

I'm deployed multiple pw sites already, all with nginx.

This time I need to have multiple pw sites for a domain, every one of them under a subdirectory.

I've been trying many things, every time I get 404 or 500 errors on /directory/processwire ( the /directory/ works, other pages not ).

Did someone already managed to get that working ?

PS : Apache is not an option :)

Link to comment
Share on other sites

This is a sample website configuration for that works under domain.com/tr  subdirectory (for historical reasons). Though it is a WordPress site, I think it might be similar (location /tr/ part)

code is:

server {

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

        server_name domain.com;

        location / {
                # try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }
        location /tr/ {
                try_files $uri $uri/ /tr/index.php?$args;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {

        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
}
  • Like 1
Link to comment
Share on other sites

Weirdly, I've added that in index.php :

if (isset($_GET['it'])) {
  $_GET['it'] = str_replace($rootURL, "/", $_GET['it']);
}

on line 68 and now it works

in my nginx file I just added : 

location /mysite/ {
  try_files $uri $uri/ /mysite/index.php?it=$uri&$args;
}

Is this a bug ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...