301 Redirect Issue with Azure Web App

Kameron Kennemer 0 Reputation points
2023-11-03T22:27:34.51+00:00

I am seeking assistance with a 301 redirect issue on my Azure-hosted WordPress site(app service web app). Despite configuring application-side 301 URL forwarding to redirect from www.mydomain.com to mydomain.com, and vice versa. The redirects are consistently not working. I also tried doing it server-side with the nginx.conf file to include redirect rules server block and they had no effect. My site exists as both which I don't want. Dont really care which, just want one. A record in Azure points to IP C name points to the default Azure address, app service ssl cert works, and everything is bound. Just stuck with two URLs and want only one. I've been messing with this for months and I'm sick and tired of it. Any ideas? Something changed in the last update where your default URL would change from the Azure one to your custom domain name but now it does not and the instructions have not been updated.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2023-11-07T19:34:57.4966667+00:00

    I see @Kameron Kennemer and thank you for the additional context.

    Since you modified your nginx configuration, it may not be taking affect. Make a copy of /etc/nginx/sites-enabled/default and place it the site home directory. Then, create a startup.sh script that uses the new configuration.

    #!/bin/bash
    
    cp /home/site/default /etc/nginx/sites-enabled/default
    service nginx reload
    

    Refer to NGINX Rewrite Rules for Azure App Service Linux PHP 8.x for details.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.