Set up nginx to redirect access from xx.com to www.xx.com.

You can automatically redirect requests to xx.com to www.xx.com by modifying the Nginx configuration file. Below is an example configuration:

server {
    listen 80;
    server_name xx.com;
    return 301 http://www.xx.com$request_uri;
}

Please add the above code to the server block in your Nginx configuration file. Then reload the Nginx configuration file for the changes to take effect.

Please note that the above configuration will redirect all requests from xx.com to www.xx.com, including both the main domain and subdomains. If you only want to redirect the main domain to www domain, you can use the following configuration:

server {
    listen 80;
    server_name xx.com;
    return 301 http://www.xx.com$request_uri;
}

server {
    listen 80;
    server_name *.xx.com;
    return 404;
}

This will redirect requests from xx.com to www.xx.com, but requests for any subdomains (such as subdomain.xx.com) will return a 404 error.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds