custom domain redirect to default abc.azurewebsites.net urls on Azure WordPress site

Saram 0 Reputation points
2024-05-03T16:48:42.2433333+00:00

Hello,

My Azure WordPress site domain redirects to my default abc.azurewebsites.net. urls. DNS is all set up and secure. Wordpress general setting is also set on Custom domain. The site did accessed through custom domain abc.com But all pages URLs are on default abc.azurewebsites.net. This link also has the same issue but I can't find any working solution here.

https://learn.microsoft.com/en-us/answers/questions/1338232/xxx-azurewebsites-net-doesnt-redirect-to-custom-do?page=1&orderby=Helpful#answers

Site wp-config.php file has this code

//Relative URLs for swapping across app service deployment slots
define('WP_HOME', $http_protocol . $_SERVER['HTTP_HOST']);
define('WP_SITEURL', $http_protocol . $_SERVER['HTTP_HOST']);
define('WP_CONTENT_URL', '/wp-content');
define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST']);

How can I edit it to point to my Custom domain URL. I have no experience with linux or how to use this solution. https://azureossd.github.io/2020/03/30/Redirect-the-.azurewebsites.net-domain-to-your-custom-domin-with-Nginx/

Also, site can be accessed through a custom domain and DNS is on Azure IP But when you try to reach it through IP address it gives a 404 error. Site is using Cloudflare nameserver, If that is the reason for this problem.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,586 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,408 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 24,971 Reputation points Microsoft Employee
    2024-05-06T18:54:33.4366667+00:00

    @Saram , Apologies for the delay from over the weekend. I understand that have tried multiple steps to isolate this issue.

    Firstly, just to highlight App Service support HTTPS on *.azurewebsites.net domain name and the certificate is provided and owned by Azure.

    By default, http://yourdomain.azurewebsites.net works even with custom domain added, and the site admins aware about the URL can access, but typically end users would not access this URL directly (unless explicitly shared).

    Typically, the redirection can occur for two reasons:

    1. URL settings on the database. There are two fields named SITEURL and HOME within the wp_options table that control the URL redirects.
    2. Defined constants in wp-config.php

    On App Service: The wp-config.php files can be updated using either Kudu console or FTP Client (such as FileZilla). Try the steps (double-check) as outlined (A-D) in this article.

    1. Browse to Kudu : http://”yoursitename”.scm.azurewebsites.net.

    Example: if your Azure App Service Web App name is “testwebapp”, then surf to http://testwebapp.scm.azurewebsite.net

    1. Click ‘Debug Console’ and select ‘CMD’

    Traverse to wwwroot folder

    1. For WordPress, update wp-config.php

    -make necessary changes, and save.

    Additionally, you may try adding a robot.txt file for google indexing the site as mentioned by Peter on SO discussion thread.


     If the answer helped (pointed, you in the right direction) > please click Accept Answer - it will help users to find the answers quickly.

    0 comments No comments