Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Django URL中将www更改为其他内容?_Python_Django_Url_Nginx_Django Urls - Fatal编程技术网

Python 如何在Django URL中将www更改为其他内容?

Python 如何在Django URL中将www更改为其他内容?,python,django,url,nginx,django-urls,Python,Django,Url,Nginx,Django Urls,我已经为我的Django应用程序创建了一个rest API,但是我如何去API.website.com而不是像www.website.com/API这样的东西呢 顺便说一句,我正在使用nginx,如果这与nginx配置中的这个有任何关系,请添加类似的内容。这会将api.website.com上的所有请求传递到您的gunicorn套接字->django应用程序 server { listen *:80; server_name api.website.com; locat

我已经为我的Django应用程序创建了一个rest API,但是我如何去API.website.com而不是像www.website.com/API这样的东西呢


顺便说一句,我正在使用nginx,如果这与nginx配置中的这个有任何关系,请添加类似的内容。这会将api.website.com上的所有请求传递到您的gunicorn套接字->django应用程序

server {
    listen *:80;
    server_name api.website.com;

    location ~ ^/api(.*)$ {
      try_files $uri $1 /$1;
    }

    location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;

      proxy_set_header Host $http_host;
      proxy_redirect off;

      proxy_pass http://gunicorn_socket/;
    }
}