I have created a project where i have same code for multiple websites which is running with add on domain and few with sub domain.
Now i have a issue, i have installed SSL certificate and redirect it to https using .htaccess file for one add on domain but because it has same code base SSL has been forced on all the add on domains.
I want SSL to be integrated on specific add on domains.
Place the .htaccess file in the domain you want to have the redirect and create different .htaccess files in sub domain with different rules.
Related
I created a static page using Azure Storage and CDN with Microsoft Standard pricing tier. I need to redirect user from example.com to https://www.example.com (with www), but my rules doesn't seem to work - only http to https redirection rule works so when I type example.com I'm redirected to https://example.com
That's my rules configuration:
That's domain records:
Both options are added in custom domains for this cdn:
The problem is that at first user is forwarded to https://example.com where there is no cert and privacy error appears and rules are not applied.
Rules could be changed to this:
so now user is forwarded from example.com to https://www.example.com, but if somebody will type https://example.com he will still see an error. Solution to this could be buy SSL cert, because Azure CDN doesn't allow CDN Managed SSL for apex domain.
Goal
Redirect root/apex domain to WWW subdomain, using Azure CDN without buying/making your own cert.
Can this be done?
Yes
How?
Use below config, remember to use Moved 301, not "Permanent Redirect 308"
I own for a website (example.com (GoDaddy)) and I set the name servers to Azure and manage DNS from there. I don't know enough about DNS to know how to properly do what I'm trying to do or the pros/cons. I have SSL always set in my AppService.
I want www.example.com to forward to example.com (on both http and https). Currently, I have both registered and bound to a cert in the AppServices and it works over https. The following links work in fact.
http://example.azurewebsites.net forwards to -> https
https://example.azurewebsites.net works/secure (seems to be using *.azurewebsites.net cert)
http://example.com forwards to https://example.com
https://example.com works/secure using example.com cert
http://www.example.com (forwards to https)
https://www.example.com (works using example.com cert).
So, all of these work and are secure... but I'd like ALL of them to forward to the naked and secure: https://example.com
I setup (In Azure) www CNAME to point to example.azurewebsites.net. Can I get this to happen through dns configuration or do I need to modify the actual AppService code to detect www and forward?
Also, if later I want someOtherAPI.example.com (can it point to another totally different AppService and use the same cert or will it need another cert?
It seems you want to know two points in your question:
So, all of these work and are secure... but I'd like ALL of them to
forward to the naked and secure: https://example.com
By default, Azure provides a wildcard cert *.azurewebsites.net for the domain azurewebsites.net, so you could use https for the domain and its subdomain. If you want to forward all traffic forward to the URL https://example.com, you need to change your code like URL rewrite or URL redirect in the web.config file. View More details here1 and here2
Also, if later I want someOtherAPI.example.com (can it point to
another totally different AppService and use the same cert or will it
need another cert?
The SSL cert DNS name must match the domain name in the website URL. So if you want to secure the website for the domain someOtherAPI.example.com, you need an SSL cert DNS name as someOtherAPI.example.com or wildcard domain *.example.com for this website.
Hope this could help you.
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.
We recently created a new web site and I performed the following steps to redirect users from the old domain to the new one:
updated the old domain and its appropriate CNAME's to forward to the new domain
configured Azure to listen for the old domain + subdomains
added URL rewrite rules to the web.config (301 permanent redirect to new domain)
Everything works fine when browsing via HTTP; however, when browsing via HTTPS, I get errors such as
The hostname in the website’s security certificate differs from the
website.
This server could not prove that it is [old domain]; its security certificate is from *.azurewebsites.net.
I am guessing this is because my app service only holds the SSL certificate for the new domain name, and not the old one. Is there any way around this? Can URL rewriting or some other option preempt this?
You can have the certificates for your new and old domains in the same App Service application.
You need to add both certificates, and then add the SSL binding for each one to the appropriate domain.
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.