How to fix canonical issues with WordPress on App Services

Joe O 0 Reputation points
2023-01-28T13:29:04.7433333+00:00

I need to redirect www.example.com to example.com. I have a custom domain with SSL, https enforced. Http requests are being redirected to https and working as expected. Where, or how, do I configure a redirect to get the www.example to redirect to example.com?

The WordPress site was installed on App Services as described here:

https://learn.microsoft.com/en-us/azure/app-service/quickstart-wordpress

This version of the the installation uses PHP v8 on nginx. As mentioned, I have a custom domain with example as the A record and www.example as a cname on that domain. Each is secured with individual free SSL certificates from App Services, with bindings. The app is configured to enforce https.

Any assistance would be greatly appreciated.

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
937 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,075 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,319 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,685 questions
{count} votes

2 answers

Sort by: Most helpful
  1. JimmySalian-2011 41,891 Reputation points
    2023-01-28T13:59:18.4533333+00:00

    Hi,

    Do you use App Gateway as this might assist in redirection and applying L7 policies as well. If not try this process -

    https://www.zainrizvi.io/blog/block-default-azure-websites-domain/

    https://techcommunity.microsoft.com/t5/apps-on-azure-blog/azure-application-gateway-app-service-redirects-exposing-default/ba-p/898576

    Hope this helps.

    JS

    ==

    Please Accept the answer if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.
    0 comments No comments

  2. SnehaAgrawal-MSFT 17,761 Reputation points
    2023-02-03T06:18:28.89+00:00

    Thanks for reaching here! It seems you are using WordPress site is hosted on Linux for this your app root directory (/home/site/wwwroot), is using the new PHP 8 blessed image, which uses nginx as webserver in place of Apache.

    For configuring redirect suggest you to refer this blog postfor how to make rewrite rules for nginx using the .htaccess file.

    Let us know if further query.

    1 person found this answer helpful.
    0 comments No comments