xxx.azurewebsites.net doesn't redirect to custom domain after setting up

Xu Wang 40 Reputation points
2023-07-28T00:59:53.3166667+00:00

My Azure Wordpress app servcie landlordgurus.azurewebsites.net doesn't redirect to landlordgurus.com even though custom domain was already setup correctly. landlordgurus.azurewebsites.net is built using "Wordpress on app service". My other websites using old App service does redirect to the custom domain. landlordgurus.com domain is bought from GoDaddy, using Name server from Ezoic (for performance). Wordpress Address (URL) and Wordpress Address (URL) in Wordpress settings are both set to https://landlordgurus.com.

Maybe for that reason, some Google search results shows pages from landlordgurus.azurewebsites.net instead of landlordgurus.com, which is the main problem.

Please help!

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
{count} votes

Accepted answer
  1. SnehaAgrawal-MSFT 21,006 Reputation points
    2023-07-31T06:58:21.96+00:00

    @Xu Wang Thanks for reply! You may follow the steps mentioned in this blog to update the Nginx configuration file to redirect your users from azurewebsites.net & to your custom domain.

    1. Go to Azure Portal, open a new SSH session. (https://<your-site-name>.scm.azurewebsites.net/webssh/host)
    2. Update Nginx Default.conf - Server Block (Edit- file is under /etc/nginx/conf.d/default.conf)
    3. Update Nginx Default.conf - Location Block
    4. Save Changes
    5. Use command nginx -s reload to restart the Nginx Service & load the new configuration so that your redirects should be working as expected.

    Hope this helps. Let us know.

    2 people found this answer helpful.
    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Saram 0 Reputation points
    2024-05-03T16:16:54.23+00:00

    Hello, My WordPress site on Azure also having this issue custom domain opens site but its directed to azure default url when other pages open. The general setting is on the custom domain. Is there any working solution for this? I can't find a solution for this anywhere. The azure support didn't work.

    Will this work?

    define('WP_HOME','http://www.example.com');

    define('WP_SITEURL','http://www.example.com/site');

    My site has these line in .wp-config.php file , how can I edit it to point to a custom url.

    //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']);
    
    0 comments No comments