Recently bought a new domain (cloud hosting account).Discovered that my site adds extra delay when invoked with "WWW" prefix in the browser.
However, the site does appear finally but its slower compare to invoking without "WWW"
why is this slow ? and can i improve this with any configuration ?
what is the best practice.
1]Once anyone register domain, domain name will be in naked form. Purpose is to link it to specific IP.Suppose example.com is domain name which is naked domain name linked to specific IP.Once domain is created, zone will be created too for it.
2]www.example.com shows sub domain of domain example.com and it has zone records automatically set which is of main domain example.com.So whenever someone browse www.example.com,it tries to identify zone records of example.com and then displays website.Hence there could be slight delay(mili seconds) while one would browse www.example.com compare to example.com
3]One should bind domain with www and without www
Related
I'm working on a site that only works if you type in www. Only the www subdomain has an A record. The bare/naked domain is unable to be given an A record. The naked domain can also not be given a DNS Alias. This means the site without "www" shows an error in your browser.
I'm trying to think through any creative solution that may solve this usability issue.
Would an htaccess rewrite rule such as:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
work in this scenario to force users to the www working site and to keep users from seeing an error in their browser?
I'm thinking it likely does NOT work because the htaccess file would only be accessed when users already typed in www (which has the A record). Is that thinking correct?
(Additional examples of htaccess code are in this thread) Redirect non-www to www in .htaccess
If this isn't a valid option, any other creative solutions that might work?
No, .htaccess rules won't work if the DNS isn't pointing to them. The only way to issue a redirect is by pointing the DNS to a web server that redirects.
CNAME records never work for the domain apex, so they are never an option. The only DNS records that will resolve a website for the domain apex are A records. I suspect that you are using a web host that doesn't give you an IP address to put into the A record, only a name. They probably warn that the IP address could change without warning. There are other possible solutions in this type of situation:
Let your web host be your DNS host
Many web hosts will offer to host your DNS for you. They can then keep your A and CNAME records up to date for you. They would be able to use A records at the APEX and change them as needed. If your web host offers this service, you would change your NS records at your DNS registrar to point to values given to you by your web host. Usually something like ns1.example.com and ns2.example.com.
Use ANAME or ALIAS records
Many DNS hosts now allow your to enter a name but serve it as an A record. The DNS host periodically (like every few minutes) looks up the IP address for the name and serves an A record with the current value. These records have different names at different DNS hosts, but they are usually called ANAME or ALIAS records. If your current DNS host doesn't offer this service, you could switch to a more capable DNS host that does so.
Use a third party redirect service
If your existing web host won't give you an IP address to use in an A record, you can use an alternate web host that will do so for the redirects. Most web hosting will give you an IP address to put into DNS records that won't change without notice. It is possible to find an alternate host for your domain apex and use that hosting only to do the redirect to www. Your www CNAME record would continue to point to your existing host.
So I setup a subdomain off my regular domain. I then make an A record on Cloudflare to point to the IP address of my server. However, whenever I go to the subdomain, it just takes me back to the main hostname. (So i have sub.domain.com and when I go to sub.domain.com in my browser, it redirects me back to domain.com)
What could be the issue? I've checked .htaccess.
I've had similar issues with cPanel and Cloudflare before where cloudflare won't properly direct to the proper subdomain.
This is very difficult to look at without knowing the actual domain or subdomain in question. We don't do anything that would put a redirect in by default, so it sounds like it may be an issue on your server directly.
I would like to point CNAME records for www.example.com to sub.example2.com. The hosting for example2.com is a shared hosting (cPanel without Addon domain feature).
So, what I did was to add a subdomain in the cPanel: sub.example2.com
I then added a CNAME record for www (and without www) of example.com to sub.example2.com
After propagation, www.example.com shows the default server page of the hosting instead of showing the sub domain contents. If I access this subdomain directly, it works fine.
Can somebody help me with these, please? Thanks.
If I understood your intent correctly, you have to tell cPanel that you want to serve www.example.com, not the other thing. Either that, or create a third virtual host somewhere (anywhere) that would handle www.example.com by doing a HTTP redirect to sub.example2.com.
Note also that you can't have a CNAME record for example.com without www, because a domain record already has SOA and NS records, and CNAME can't be combined with anything else - it has to be an A record.
Another thing to know about what you're doing:
You can't use a CNAME in the zone apex
(so as in the example.com zone a record "# IN CNAME example2.com")
Theoretically it is, but in reality too many (resolving) nameservers get confused.
I am using Namecheap for domain registration and for DNS, and using Heroku for hosting. I have purchased an SSL certificate through Namecheap and set it up with Heroku, and have it nearly working perfectly.
Currently, I have a DNS CNAME record with host "www" pointing to "[whatever].herokussl.com.", and a "#" host record set to URL Redirect (301) to "http://www.[domain].com".
My app itself forces all HTTP traffic to redirect to HTTPS, so "http://www.[domain].com" goes to "https://www.[domain].com".
I am getting the following results:
http://www.[domain].com - properly navigates to site as HTTPS
https://www.[domain].com - properly navigates to site as HTTPS
http://[domain].com - properly navigates to site as HTTPS
https://[domain].com - **does not** navigate to site, and instead the browser cannot find the page
I believe this has to do with how the URL Redirect behaves behind the scenes. I had originally done this as CNAME record pointing directly to "[whatever].herokussl.com.", but apparently doing that on the zone apex blocks MX records...
What do I need to do to get the desired behavior? I simply want all naked or "www" domains to point to my "www" domain.
UPDATE: More information regarding my DNS settings
HOST NAME IP ADDRESS/URL RECORD TYPE
--------- -------------- -----------
# http://www.[domain].com URL Redirect (301)
www [whatever].herokussl.com. CNAME (Alias)
My SSL certificate was not a wildcard, just an EssentialSSL certificate from Comodo. I'm fine if only www.[domain].com works (with a redirect from the naked domain), although when I was using a CNAME for both the apex and "www", it was working as a naked domain with SSL just fine.
If you use DnsSimple, you can use their ALIAS record feature.
The DnsSimple ALIAS record is not a standard DNS record type, and is not the same thing as a CNAME record. Rather, DnsSimple supports it in a special way, by performing the DNS resolution for you and returning to your browser the results. This is different from all other DNS records, where the DNS server performs no processing but simply returns the record to your browser on-demand.
There may be other DNS vendors with their own similar features.
However, with only vanilla DNS, HTTP-only 3xx's from your nameserver, and Heroku, there is no way to get SSL to the zone apex (the domain name with no www.).
I'm trying to redirect all subdomain requests for domain.com to www.domain.com even when the subdomain does not exist, for example if we have:
abc.domain.com to www.domain.com
Where abc can be any requests. Furthermore, that subdomain abc may be exists or not. But whatever it is, I want to redirect it to main domain.
And less important request is. How it is possible to keep the input address at the address bar and redirect to main domain?
It will be best for me if it is done by .htaccess
I use apache server.
Thank you.
Since you haven't specified the environment you use, here are some general tips:
First, there is a difference between redirecting:
The user types sub.domain.com into the browser's address bar, but is redirected to domain.com -> domain.com is in the address bar, as the user is now on domain.com
...and rewriting an URL in the background:
The user types in sub.domain.com and stays at this address. The user sees sub.domain.com but in the background some other page (in your case, that one under domain.com) is loaded and shown.
(Quickly explained.)
If you are using Apache, take a look at 301 redirects and url rewriting.
In addition to what Piedone said (which is on the HTTP server side), you also need to configure the DNS to have a catch-all for all subdomains, directing them all to your HTTP server.
This implicitly means that all possible subdomains will exist automatically.