How to Redirect www to non www on Nginx
I just moved from my shared hosting plan to cloud VPS on Contabo and found that the www version of my website is showing Welcome to Nginx! page. I installed Aapanel to manage and configure my website, it’s like CPANEL on shared hosting.
Here are the steps required to fix that problem:
- Login to Aapanel and click Website
![How to Redirect www to non www on Nginx 1 www to non www](https://yunarwinardi.com/wp-content/uploads/2023/12/www-to-non-www.jpg)
2. It will show your all websites, on the website you want to configure, click Conf
![How to Redirect www to non www on Nginx 2 www to non www1](https://yunarwinardi.com/wp-content/uploads/2023/12/www-to-non-www1-1024x51.jpg)
3. You will see below window (Domain Manager), add www.yourdomain.com, click Add
![How to Redirect www to non www on Nginx 3 www to non www2](https://yunarwinardi.com/wp-content/uploads/2023/12/www-to-non-www2.jpg)
4. After adding you will see similar to the below window.
![How to Redirect www to non www on Nginx 4 www to non www3](https://yunarwinardi.com/wp-content/uploads/2023/12/www-to-non-www3.jpg)
5. From the left menu click Redirect, click Add Redirection
![How to Redirect www to non www on Nginx 5 www to non www4](https://yunarwinardi.com/wp-content/uploads/2023/12/www-to-non-www4.jpg)
6. Click Source and choose the www version of your domain, on target URL type https address of your version as below.
![How to Redirect www to non www on Nginx 6 www to non www5](https://yunarwinardi.com/wp-content/uploads/2023/12/www-to-non-www5.jpg)
Click Submit and you are done.
Click on the browser to make sure that your www version of the website correctly redirect to non www version as this website. Thank you.