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

This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .

1. Navigate to your App Service via the Azure Portal. Under the Development Tools section, select SSH then Go -->.

Arjun_Baliga_0-1680874535337.png

 

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

 

 

 

Arjun_Baliga_1-1680874333968.png

 

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

Arjun_Baliga_2-1680874333972.png

 

  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. 

Leave a Reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.