要查看示例:加载example.com,单击链接到/ test的链接,而不是转到http:// example.com/test/,它转到http:// www.example。净//测试/
或者,如果您登录,则自动生成的django admin部分的登录表单会发布到// admin而不是admin。
似乎这是一个django问题,但我唯一改变的是nginx。
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
server {
listen 80;
server_name www.site.net;
location / {
fastcgi_pass unix:/path/to/site/server.sock;
include fastcgi.conf;
access_log /var/log/nginx_django.log main;
}
location ^~ /admin/$ {
fastcgi_pass unix:/path/to/site/server.sock;
include fastcgi.conf;
access_log /var/log/nginx_django.log main;
}
location ~* ^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg))
$ {
root /path/to/site/media;
limit_rate 2000K;
access_log /var/log/nginx_django_media.log download;
access_log off;
}
location ^~ /static/ {
root /path/to/site;
access_log /var/log/nginx_django_static.log download;
expires 30d;
}
location /403.html {
root /opt/nginx;
access_log off;
}
location /401.html {
root /opt/nginx;
access_log off;
}
location /404.html {
root /opt/nginx;
access_log off;
}
location = /_.gif {
empty_gif;
access_log off;
}
}
答案 0 :(得分:3)
fastcgi_param SCRIPT_NAME '';
这为我解决了//
问题。