Reputation: 261
I have a Wordpress Blog hosted on an Azure Website. The blog itself works great, and the Custom domain resolves correctly to the Azure WebSite URL. However, I'm hoping to configure the site such that the user's browser will always display the custom domain, even when they click a link within the site, rather than what happens now, which is as soon as you click any link within the site, the URL changes to the http://MyBlog.AzureWebSites.Net/{Content Url} URL. I see the related question Custom Domain Name on Azure site working, but always redirects to azurewebsites.net?, but disabling Domain Forwarding in GoDaddy doesn't solve this URL issue.
The goal is to have the entire site working under www.MyBlog.com/ in the user's browser rather than http://MyBlog.AzureWebSites.Net/{rest of the url} as soon as they click any link . As per the documentation Configure a custom domain name in Azure App Service, I have configured the CNAME and averify records which point to the Azure Web Site's IP address with GoDaddy, as well as adding the "Custom Domain" via the Azure Portal. The URL www.MyBlog.com does resolve correctly to http://MyBlog.AzureWebSites.Net, and it stays as www.MyBlog.com until the user hits any link inside the site (say, opening a post), at which point, the URL becomes http://MyBlog.AzureWebSites.Net/2015-12-01/MyFirstPost
I see some articles on how to achieve this with changes to the web.config file, such as SEO Tip: How to block the *.azurewebsites.net domain, which suggests adding this to the Web.Config:
<rule name="Disable Azure Domain" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="*.azurewebsites.net" />
</conditions>
<action type="Redirect" url="http://www.example.com{REQUEST_URI}" redirectType="Permanent" />
</rule>
but whenever I try to make this change, both URLs stops resolving. They appear to go into an infinite loop redirecting to each other.
I'm not trying to redirect from one URL to another. Essentially, I want the webserver to always replace the http://MyBlog.AzureWebSites.Net/ part of the URL with www.MyBlog.com/ . It's worth noting that when I manually enter www.MyBlog.com/2015-12-01/MyFirstPost, it serves the page correctly.
Upvotes: 0
Views: 1683
Reputation: 4599
This isn't an Azure issue, rather a Wordpress Issue.
When you set up Wordpress site you choose the site domain and then this is used throughout the site.
On the Settings-> General screen there is a field called "Site Address (URL)". The "Site Address (URL)" setting is the address you want people to type in their browser to reach your WordPress blog.
It sounds like you will want to update this field.
More information can be found here: https://codex.wordpress.org/Changing_The_Site_URL
There are plugins that make this easier Such as Velvet Blues Update URLs not only changes the Site URL but updates any internal links or images embedded in pages that wouldn't ordinarily be updated.
Upvotes: 2