Guest Arjun_Baliga Posted April 7, 2023 Posted April 7, 2023 1. Navigate to your App Service via the Azure Portal. Under the Development Tools section, select SSH then Go -->. 2. Modify the default site config - You would need to make a copy of the existing configuration and place the file inside the /home/site directory by running the below command. cp /etc/nginx/conf.d/default.conf /home/site/default Go to https://<app name>.scm.azurewebsites.net/newui/fileManager click on Modify site/default file. in the existing server block update the server name to www domain server { listen 80; ## Your website name goes here. server_name www.example.com In the same default.conf file, you can create a new server block and add the below configurations for non-www to www redirection - server { listen 80; server_name example.com; return 301 $scheme://www.example.com$request_uri; } // This directive tells Nginx to send any request //for http://example.com to http://www.example.com with HTTP redirect code 301. Copy the following code snippet to /home/dev/startup.sh. cp /home/site/default /etc/nginx/conf.d/default.conf /usr/sbin/nginx -s reload Please restart App Service and verify that the redirect from non www domain to www domain works fine. Continue reading... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.