[英]How do you append www. to a Django url?
Currently I am using nginx and uWSGI to host my website. 目前,我正在使用nginx和uWSGI托管我的网站。 I need to append www.
我需要附加www。 to my urls, but I'm not sure what is the best route to take.
到我的网址,但是我不确定最好的方法是什么。
Should I be doing this at the nginx level? 我应该在nginx级别上执行此操作吗?
Yes, nginx is the most efficient way to prepend (or append) www
, though Django provides a settings PREPEND_WWW
that does the exact same thing when set to True
. 是的,尽管Django提供了设置
PREPEND_WWW
,当设置为True
时,nginx是前缀 (或附加) www
的最有效方法。
Eg in your nginx config: 例如在您的nginx配置中:
server {
listen 80;
server_name example.com;
return 301 http://www.example.com$request_uri;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.