Blog Post

Apps on Azure Blog
1 MIN READ

Redirect from the non WWW domain to the WWW domain in the Azure WordPress Market Place offering-

Arjun_Baliga's avatar
Arjun_Baliga
Icon for Microsoft rankMicrosoft
Apr 07, 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

 

 

 

 

  1. Go to https://<app name>.scm.azurewebsites.net/newui/fileManager click on Modify site/default file.

 

  1. 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

 

 

 

  1. 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.

  1. 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

 

 

 

  1. Please restart App Service and verify that the redirect from non www domain to www domain works fine. 
Updated Apr 07, 2023
Version 1.0
No CommentsBe the first to comment