I've got Django running behind Nginx with `fastcgi_pass`. I run Django at a subpath like `/django/sample`.

```
location /django/sample {
    include fastcgi_params;
    fastcgi_pass 127.0.0.1:8025;
}

```

I use `FORCE_SCRIPT_NAME` in the Django settings module, which seems to fix all the issues I was having in regards to it running at a subpath.

In settings.py:

```
FORCE_SCRIPT_NAME = "/django/sample/"

```

I go here to login with admin (and correctly get the admin UI):

```
http://server/django/sample/admin

```

But when I submit, it redirects to:

```
http://server/django/sample/django/sample/admin

```

What's really strange is that if I change `FORCE_SCRIPT_NAME=""` the login works.

BUT, then all of the links in the admin page are `/admin`, not `/django/sample/admin/`

What the heck am I missing? Setting `FORCE_SCRIPT_NAME="/django/sample/"` seems to fix everything except admin login.

Any ideas?

**UPDATE:**

I've also tried using `fastcgi_split_path_info` in nginx conf (and take out `FORCE_SCRIPT_NAME` in settings). Again, that fixes all the path issues except the admin login redirect.

conf like this:

```
location /django/sample {
    fastcgi_split_path_info ^(/django/sample)(.*)$;
    include fastcgi_params;
    fastcgi_pass 127.0.0.1:8025;
}

```