Correct way to redirect non www to www for the domain using Nginx webserver?

SYSTEM INFORMATION
OS type and version AlmaLinux 9
Virtualmin version 7.20.2

Hi, I am a new user of Virtualmin. I have recently completed a fresh installation of Virtualmin on AlmaLinux 9. I successfully installed and created Let’s Encrypt SSL certificates for both example. com and www.example. com, and I have set all requests to be redirected to the SSL site under Virtualmin → Web Configuration → Website Options. Everything is working as expected.

However, I have been struggling to find a clear solution online for permanently redirecting the domain from example. com to www. example.com. Is there a way to configure this within the Virtualmin or Webmin UI? Thank you in advance.

@jahir3819,

For Apache based setup there is a section:

Website Configuration > Website Options

This page has a configuration as shown below to accomplish this task easily.

Failing that, another area that “might” be available (I don’t use Nginx with Virtualmin personally) would be under:

Website Configuration > Website Redirects

*** The first option actually indirectly configures a redirect on this page for Apache ***

Screenshot from 2024-11-09 23-01-57

Again, this is from a system that uses Apache NOT Nginx, though it’s possible the options are there and the system configures Nginx when it’s being used.

Let me know if this helps at all.