S
S
Salavat Sitdikov2012-06-18 09:17:20
Nginx
Salavat Sitdikov, 2012-06-18 09:17:20

Rewrite to nginx?

How to make a redirect from www to a domain without www is understandable. I wanted to ask for help setting up a redirect from www-subdomains. That is, subdomains are available via www.subdomain.servername.ru , but I would like to redirect them to subdomain.servername.ru
server {
server_name www.servername.ru;
rewrite ^(.+)$ servername.ru$1 permanent;
}


Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VBart, 2012-06-18
@zona7o

server {
    server_name ~^www\.(.+)\.example\.com$;
    return 301 $1.example.com/$request_uri;
}

M
Michael, 2012-06-18
@1099511627776

server {
server_name ~^www\.(.*?)\.example\.com$;
rewrite ^www\.(.*?)\.example\.com$ $1\.example.com permanent;
}
somewhere like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question