How to set the redirect rules in Nginx based Wordpress Image

1 minute read | By Arjun Baliga

Our Wordpress on Linux image is Nginx based and if you’d like to configure the redirect rules, please follow the steps below

  1. Start and access your site in a browser and open a direct SSH session with your container.
    Paste the following URL into your browser and replace <app-name> with your app name:
    https://<app-name>.scm.azurewebsites.net/webssh/host
  2. Run the following commands to update the Nginx configurations -
    cd /home/etc/nginx/conf.d
    vi default.conf
    Press I and switch to Insert mode
  3. Based on your requirement update the redirect rule below in the “location” section
    Please use the below syntax if the redirect is to the different folder -
    location /global/ {
    try_files $uri $uri/ /global/index.php?$args;}
    The below syntax can be used in case if you’d like to redirect the URLs to the different domain.
    /global/about.php {
    rewrite ^(.*)$ https://www.yourdomain.com/foo/bar redirect;
    }
    nginx rules
  4. Save the new settings by pressing ESC and :wq!
  5. Restart your site and test the redirect rules.