Redirect www to non-www on Azure Dns Zone - azure

I have created Azure DNS Zone to manage redirections which use domain from namecheap.
Let's assume that my website is www.johndoe.com and currently website working well for johndoe.com but when I call www.johndoe.com it doesn't work well.
I have CNAME record and in CNAME redirect to redirect but unfortunately it doesn't work.
When I have call www.johndoe.com response message is as following...
Our services aren't available right now
We're working to restore all services as soon as possible. Please check back soon.

Please take into account that DNS does not provide a redirect.
An additional A or CNAME record only provides your IP address to people that navigate to that specific URL. When www.johndoe.com and johndoe.com both resolve to your web server, this means each page on your site has two addresses. This is horrible for things like SEO.
For a true redirect (and a 301 is preferred for SEO), set something up in the service that's handling the traffic coming in.
For instance: if you have an App Service running ASP.NET, setup the redirect in web.config. If you have Front Door (or a CDN) in place, use the rules engine to create a redirect with the correct condition and action.
Here's an example redirect in an Azure Front Door Classic Resource (this one redirects the other way):

Related

AddRedirectToWww() redirecting to wrong domain

I'm using the AddRedirectToWww rule for the rewriter middleware and I keep getting redirected to the wrong domain.
For context, my website is hosted on azure app service which has a default domain of myapp.azurewebsites.net. I have a custom domain say myapp.com and www.myapp.com.
I setup the rule so traffic from myapp.com gets redirect to www.myapp.com. However, what is happening is upon hitting myapp.com I get a redirect towards www.myapp.azurewebsites.net.
Any reason for why this is so? Does this middleware require specific request headers to determine the right host?
From the scenario and configuration you described, it looks like you have not set CNAME and TXT record correctly. You need to configure this in your Domain Registrar/Provider.
You need to map a subdomain (for example, www.myapp.com) by using a CNAME record.
Map a root domain (for example, myapp.com) by using an A record.
Kindly refer this document for step-step process.

Custom Domain to Azure CDN Endpoint with and without www

I have created an Azure CDN, an endpoint and working fine.
Created a CNAME www.mydomain.com to myazurecdn.azureedge.net
Created another CNAME mydomain.com to www.mydomain.com
In Azure Endpoint, Custom Domain, I updated www.mydomain.com and it got propagated.
Now, when I navigate to www.mydomain.com, everything works fine but when I navigate to mydomain.com i get below response.
Our services aren't available right nowWe're working to
restore all services as soon as possible. Please check back soon.
Note: As Azure endpoint accepts multiple custom domain, I could add both www.mydomain.com and mydomain.com but it is not correct way, as I have many <a> tags with www.mydomain.com/link.
What to be done now to instruct system to use same route for mydomain.com and www.mydomain.com?
Is domain redirect from domain.com to www.mydomain.com only option?
Have a look at this,
A custom domain and its subdomain can be associated with only a single
endpoint at a time. However, you can use different subdomains from the
same custom domain for different Azure service endpoints by using
multiple CNAME records. You can also map a custom domain with
different subdomains to the same CDN endpoint.
You can use different subdomains in the same endpoint. Alternatively, I think you also could create two endpoints, one is for the root domain without www, the other is for a subdomain with www.
I would say, you can implement redirection in your server or CDN.
When someone tries to access example.com, you can do a 301 by sending http://www.example.com in the location header.

Azure Front Door and DNS Configuration for SSL "bare" (without www) Custom Domain

I've successfully configured SSL / HTTPS for my custom domain - with a "www" in the URL - using the Azure Front Door product. That configuration required a DNS CNAME entry that forwards "www.cutegoat.com" to "cutegoat.azurefd.net"
I still have an SLL problem when I go to the same URL without the "www" prefix: "https://cutegoat.com"
My A Type DNS record still points to an IP address that Azure gave me for my App Service. I thought about changing that, but the Azure Front Door designer is pretty clear that my "Custom host name" must have a corresponding CNAME record:
I'm using GoDaddy for my domains and I've added a CNAME record with a source of "cutegoat.com", but I still get the Azure Front Door "CNAME record required" error. That entry let's me add a mapping to "cutegoat.com.cutegoat.com"
I think the Azure Front Door service is looking for a CNAME record with a source value of "#". But I can't enter that CNAME record, my guess is, because I have an A Type record with a source of "#" already.
Does anyone know the proper DNS / Azure Front Door configuration to get SSL working for my "bare" custom domain?
This appears to be working now, using an Alias type.
I use Azure DNS, so image is from there.
Added a new A record for the # apex
Set it to an Alias
The Frontdoor service now shows up under the Azure Resource.
Back in Frontdoor, finished up, creating a frontend host for the apex domain then worked.
Yes, since you must have an A Type record with a source of # already. You could not add such host # in the CNAME record as the CNAME limitation in RFC1034
If a CNAME RR is present at a node, no other data should be present; this ensures that
the data for a canonical name and its aliases cannot be
different.
As far as I know, currently Azure front door does not support to add Naked or root Domains to the custom host name. If you want to improve this service, you can request feedbacks or upvote this feedback--- Add Custom Apex (Naked) Domains as front end hosts for Azure Front Door Service
This is an old question but I struggled a lot with this.
I had this issue with a static web app. I needed this website to be PCI compliant so Azure Front Door was a requirement, but I couldn't make front-door accept the apex domain, and anyone typing the bare domain was getting a "this is not a secure site" (or whatever) message, so what I did is to add the apex domain (example.com) as custom domain at the static web app (this way Azure provided the SSL), and www.example.com at Azure Frond Door. Btw this last one always worked fine. A redirect at the apex domain does not work if the user types https://example.com instead of http://example.com, so you do need an SSL even for the redirection. At least this was my case.
Anyway, so I handled the redirection by code at the index.html file (Angular) with vanilla javascript at the header
<script>
let loc = window.location.href;
loc = loc.replace(/^https?:\/\//, '');
loc = loc.replace(/\/.*$/, '');
if (loc != 'www.example.com') {
window.location.href = 'https://www.example.com';
}
</script>
It may not be the best solution, but I guess the problem was solved cause we got PCI compliant.

How do i connect my windows azure website with my domain name perfectly?

I did almost everything that have described in the azure documentation briefly.
My domain names that i need to be assigned with my azure website url idaa.azurewebsites.net are mostout.com and www.mostout.com.
When trying to enter my site using any of the links added here, the site loads and works perfectly as i need.
But the problem is with my url which is getting loaded in browser url field while giving mostout.com or www.mostout.com.
It comes with the azure website url every time. What do I do now to get it working?
Make sure to set the CNAME for your service: have the www. name point to the full azurewebsites.net address.
Note that you'll:
need to have a level of service that supports custom domains with Windows Azure Web Sites,
add the CNAME from your www. domain to the azurewebsites domain (same goes for having the naked domain name via an A record or similar)
add the verification names, awverify.www.yourdomain.com and awverify.yourdomain.com
use the Manage Domains function in the portal for the web site to customize that domain name,
Things should just work then.

Disable azurewebsites.net subdomain

We have our company website hosted at Windows Azure Websites and set up an A-Record for our domain.
The problem is that one can also reach our site using the mangomint subdomain of http://azurewebsites.net (I don't want to post the full url here because Google shouldn't see this). This is bad in terms of SEO and duplicate content.
How can I disable the subdomain in favor of our main domain?
Well I don't think you can change the official azurewebsites.net DNS records, so you have only two solutions :
Find a way to disable this subdomain in the Azure Websites configuration EDIT: Not possible, from what astaykov said in the comments. thanks to him.
Make your website automatically redirect (HTTP 301, permanent redirect) the user when he lands on the subdomain.

Resources