Why does return 301 send me to a 414 Request?

September 11, 2018 146 views
Nginx Ubuntu 16.04

I have a main domain and a subdomain. I want all traffic to redirect to my subdomain. I have been trying to use return 301 and also rewrite in my nginx.conf for my default domain, but every time I do instead of the url being replaced with my subdomain; the subdomain is added on to the end of the url.

For example:
rewrite ^/(.*)$ https://domain2.com/$1 permanent; is the rewrite command I am using
and when I type in my domain the url becomes
https://domain1.com/domain2.com/domain2.com/domain2.com
forever and ever until I get the 414 request.

Any idea what is going on?

Be the first one to answer this question.