# Fix www to Non-www Redirect for Your Discourse Forum

To add a redirect from the "www" subdomain to the non-www version of your domain in Discourse, you'll need to modify your web server configuration. Here's how you can do this:

```nginx
server {
    listen 80;
    server_name www.yourdomain.com;
    return 301 $scheme://yourdomain.com$request_uri;
}

server {
    listen 80;
    server_name yourdomain.com;
    
    # Your existing Discourse configuration goes here
    # ...
}
```

This Nginx configuration will handle the redirect from www to non-www for your Discourse installation. Here's a breakdown of what it does:

1. The first `server` block listens on port 80 for requests to [`www.yourdomain.com`](http://www.yourdomain.com).
    
2. It then uses a `301` (permanent) redirect to send these requests to the non-www version of your domain.
    
3. The second `server` block is where your existing Discourse configuration should go.
    

To implement this:

1. Replace [`yourdomain.com`](http://yourdomain.com) with your actual domain name in both places.
    
2. Add this configuration to your Nginx configuration file (usually located at `/etc/nginx/nginx.conf` or in a separate file in `/etc/nginx/sites-available/`).
    
3. If you're using HTTPS (which is recommended), make sure to also set up similar redirects for port 443.
    
4. After making changes, test your Nginx configuration with `nginx -t`.
    
5. If the test passes, restart Nginx to apply the changes: `sudo service nginx restart` or `sudo systemctl restart nginx`.
    

Remember to also update your DNS settings to ensure that both the www and non-www versions of your domain point to your server.

Would you like me to explain any part of this configuration in more detail?
