Nginx clean-URLs for Drupal installed in various sub-directories

Submitted by fago on Fri, 07/15/2011 - 11:29

klausi has already posted a nice, actually working nginx configuration for Drupal on his blog. This configuration is intended for Drupal installations installed on separate (sub)domains. However, recently I came up with the need of having multiple Drupal installations in sub-directories for my development environment. To achieve that I've created the following location directive:

        location ~ ^/([^/]*)/(.*)$ {
                try_files $uri /$1/index.php?q=$2&$args;
        }

That way, you can just add as many Drupal installations as you want in sub-folders, while they are automatically clean-URL enabled. :)

perusio (not verified)

Tue, 07/19/2011 - 16:30

Running several drupal sites under a same root, is a bad idea IMHO. That's something that made sense in Apache, but which doesn't map to a production setup with nginx. Instead the easiest way of doing that is using different ports for different sites. That way you only need to change the port and add a server_name directive, possibly also the document root. And you're done: you have a production ready setup. Also regex based locations are to be avoided whenever possible they're bound to introduce unwanted side effects sooner or later.

As said I'm using it for my development, where this kind of flexibility is useful. Whether its something people want to use on production is another question. Usually you probably won't.

SEO KERALA (not verified)

Wed, 05/02/2012 - 11:21

Very informative text, thanks for sharing it!

private villas (not verified)

Fri, 05/11/2012 - 09:23

I love it when people come together and share opinions, great blog, keep it up.

private villas (not verified)

Fri, 05/11/2012 - 09:23

I love it when people come together and share opinions, great blog, keep it up.

private villas (not verified)

Fri, 05/11/2012 - 09:24

I love it when people come together and share opinions, great blog, keep it up.