perusio/drupal-with-nginx — Issue #22: Leading slash in language prefix results in 404 error
Author: borfast
Created: 2012-01-12 21:05:57+00:00
State: open

I tried this configuration with a bilingual site and when I use the language prefix, Drupal returns a 404 error. With the help of some good old print_r() "debugging", I saw that the URL variable 'q' was being passed '/pt' instead of 'pt' (the latter being what Drupal's .htaccess gives you) and after some digging I found out that for some reason [Drupal doesn't like that](https://drupal.org/node/827236).

The solution proposed by brianmercer did work, and I implemented it by adding another `location` directive to drupal.conf, like this:

```
location @drupal6_rewrite {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
```

and then adding it to the necessary `try_files` directives. For example, instead of having just try_files `$uri @cache;`, I have `try_files $uri @cache @drupal6_rewrite;`.

This appears to be a Drupal 6-only issue, and since the goal is to have a rewrite-free nginx configuration, I'm not sure how this could be added. Maybe with some comments, telling people to uncomment it to enable the fix, if they need it.