Answer the question
In order to leave comments, you need to log in
nginx django redirect without www?
The site works only on a domain without www .C www Server not found .
And just rewrite 301 didn't help. PCRE Installed. the link in sites-enabled works.
edit in sites-available.
Here is the config
server {
listen 80;
server_name domain.net;
if ($host = 'www.domain.net' ) {
rewrite ^/(.*)$ http://domain.net/$1 permanent;
}
location /static{
root /opt/asd/asd/;
}
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
location / {
include proxy_params;
proxy_pass http://unix:/opt/asd/asd.sock;
}
}
Answer the question
In order to leave comments, you need to log in
Everything is very simple. Left the settings. And I just attached the domain with www to my vps in the dns panel. And everything started working properly
server_name domain.net;
listen 80;
try:
server {
server_name www.mydomain.com;
listen 80;
return 301 http://mydomain.com$request_uri;
}
server {
server_name www.mydomain.com;
listen 80;
if ($http_host = www.mydomain.com) {
rewrite ^(.*)$ http://mydomain.com$1 permanent;
}
}
server_name site.com www.site.com
listen 1.2.3.4;
if ($host ~* www\.(.*)) {
set $host_without_www $1;
rewrite ^(.*)$ http://$host_without_www$1 permanent;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question