Disable azurewebsites.net subdomain - azure

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.

Related

Redirect www to non-www on Azure Dns Zone

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):

Setting up subdomain using google domains

I have a domain that I bought on Google Domains, and have a website hosted on it using Hugo + Netlify. I'd like to use a separately hosted blog website based on Jekyll on a subdomain with the name blog.example.com.
Looking online I was able to find - https://support.google.com/domains/answer/6072198?hl=en, which it seems like will re-direct the subdomain to a different web address, but not exactly allow me to host my site on that subdomain.
Can anyone explain to me how I can go about doing that?
You will need a CNAME record in your Google DNS:
blog.example.com will point to 192.0.2.4 (use the IP given to you)
Then the subdomain blog will be in the hands of your blog hosting provider.
If there is a CNAME record for *.example.com, you will need to replace that by www.example.com to point towards your example.com A record (which points to your default website host's IP)

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.

GitHub Pages https/www Redirect

How can I get https://www.test.com to redirect to https://test.com when using GitHub pages to host a static website?
I recently enabled TLS (provided by GitHub/Lets Encrypt) for my static site by setting A records at my DNS provider (namecheap). I've also chosen to "Enforce HTTPS" option in my GitHub repository's settings, which handles redirecting requests from http://test.com to https://test.com. I have a redirect configured through my DNS provider which forwards http://www.test.com to https://test.com, but the one missing piece of the puzzle is forwarding https://www.test.com to https://test.com.
Regarding this issue, GitHub says, "If your domain has HTTPS enforcement enabled, GitHub Pages' servers will not automatically route redirects. You must configure www subdomain and root domain redirects with your domain registrar."
... and my DNS provider says, "It is not possible to set up a URL redirect in the account for the TCP port forwarding from http://www.domain.tld (uses port 80) to https://www.domain.tld (working via port 443)."
I seem to be caught in an infinite loop of the two services saying the other should provide this functionality.
What worked for me:
Change your custom domain to be prefixed with www., like this:
Save the settings and wait until www.example.com resolves and works.
Remove the www. prefix and save again.
Wait for browser and DNS caches to invalidate.
All combinations should lead to https://example.com/ and no SSL error should appear.
GitHub Pages handles redirection between the apex domain and www subdomain automatically as long as you configure the DNS records correctly.
From the GitHub Pages documentation on configuring an apex domain:
If you configure the correct records for each domain type through your DNS provider, GitHub Pages will automatically create redirects between the domains. For example, if you configure www.example.com as the custom domain for your site, and you have GitHub Pages DNS records set up for the apex and www domains, then example.com will redirect to www.example.com. Note that automatic redirects only apply to the www subdomain.
While the docs discuss redirecting from the apex domain to the www subdomain, the reverse direction works as well.
If the apex domain is the desired target (as in this question): set the custom domain value to just example.com.
If the www subdomain is the desired target: set the custom domain value to www.example.com.
Again, this works as long as DNS records are correctly configured for both the apex domain and www subdomain, as described in the docs.
Not the point of this question, but the question When should one use a 'www' subdomain? offers some good insight on using the www or not.

Block access to a redirected subdomain on an IP basis

I have a subdomain (mail.mywebsite.com) that points to the login page that I've set up for Google apps (per their instructions). I'm currently using a CNAME record to point users to the page.
However, I'd like to restrict access to this subdomain on an IP basis (effectively create a whitelist).
Not sure if modifiying .htaccess on my server is an option, as the domain is configured in the registrar to forward to Google, not content on my server.
Any suggestions for how I could accomplish this? Thanks in advance!
If you've done this using a DNS CNAME, you have no control over who can access mail.mywebsite.com since it's not even your server that's accepting requests (it's Google's server).
Unless there's some way to setup access restrictions on Google, there's not going to be anything that you can do.
Alternatively, you can change the CNAME to point to your server, then use a reverse proxy to proxy the requests to Google. You can then use access controls to setup what IPs will be proxied and all the rest will just get 403'ed. Can't setup ProxyPass in htaccess file though, need to do it in server/vhost config, but you can use the P flag in mod_rewrite to reverse proxy for you.

Resources