Answer the question
In order to leave comments, you need to log in
Nginx How to make a redirect from www group of domains?
There are several domains that stubs for the site cling to.
The task is to redirect from www.example.(de|es|ch|uk|eu|ru|nl|pl|us|fr|jp|co|hk|in|it) to example.(de|es|ch|uk |eu|ru|nl|pl|us|fr|jp|co|hk|in|it).
server directory example:
server {
listen 80;
listen [::]:80;
server_name ~^www\.example\.(de|es|ch|uk|eu|ru|nl|pl|us|fr|jp|co|hk|in|it)$;
rewrite ^(.*) http://example.??$1 permanent;
}
server {
listen 80;
listen[::]:80;
server_name ~^www\.example\.(de|es|ch|uk|eu|ru|nl|pl|us|fr|jp|co|hk|in|it)$;
rewrite ^(.*) example.??$1 permanent;
}
Answer the question
In order to leave comments, you need to log in
server {
listen 80;
listen [::]:80;
server_name ~^www\.(?<mydomain>example\.(?:de|es|ch|uk|eu|ru|nl|pl|us|fr|jp|co|hk|in|it))$;
rewrite ^(.*) http://$mydomain$1 permanent;
}
server {
listen 80;
listen [::]:80;
server_name ~^www\.(example\.(?:de|es|ch|uk|eu|ru|nl|pl|us|fr|jp|co|hk|in|it))$;
return 301 http://$1$request_uri;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question