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.
Updated Apr 07, 2023
Version 1.0Arjun_Baliga
Microsoft
Joined September 28, 2022
Apps on Azure Blog
Follow this blog board to get notified when there's new activity