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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Click below to sign up and get $200 of credit to try our products over 60 days!