0

I would like to redirect all traffic from

www.*.abc.com to *.abc.com without www prefix . i have 1000+ subdomains on the same application which use only one nginx virtual host file in sites enabled directory .

sambit
  • 101
  • 2

1 Answers1

1

You will need to use a regular expression server_name to capture the part of the domain after the www. For example:

server_name ~^www\.(?<domain>.*\.example\.com)$;
return 301 $domain$request_uri;

See this document for details.

Richard Smith
  • 12,834
  • 2
  • 21
  • 29
  • i have this domain - https://www.*.eu.engagementhq.com . Which i am trying to configure like follows - server_name ~^www\.(?.*\.engagementhq\.com)$; return 301 $domain$request_uri; but this does not work . – sambit Mar 08 '22 at 11:10
  • 1
    To help you with your specific problem, we would need to see your configuration (use: `nginx -T` (uppercase `T`) to view the entire configuration across all included files), relevant entries from the access and error logs, and `curl -I` showing the actual and expected responses. – Richard Smith Mar 08 '22 at 11:29