DNS Redirect Clarification - dns

We have old domain name which we would like to redirect the traffic to new domain
e.g.
old.domain.com --> new.domain.com
Help/Clarification:
What's the best way to achieve this? Read about CName, ARecord, Alias etc., therefore confused which one to use and which scenario.
If we redirect old.domain.com to new.domain.com, then what will IIS/Web Server see as requested host name i.e. still sees old.domain.com or new.domain.com

If you want to redirect the traffic, i.e., you want the customer's web browser to show the change from "old.domain.com" to "new.domain.com", then you'll need to insert that redirect at the web server or code level.
If you simply want a request for "old.domain.com" to land on the address for "new.domain.com", then you can use just a CNAME in DNS.

Related

How to mask a subdomain URL with CNAME record?

I need to mask the subdomain URL http://3477er.domainB.com with https://sub.domainA.com Both in different servers.
So I create the "sub" alias in domainA server pointing to https://34tter.domainB.com with a CNAME record and waited for its propagation.
I thought I should see http://3477er.domainB.com content when I type http://sub.domainA.com in browser. Instead I get the message DNS_PROBE_FINISHED_NXDOMAIN Isn't this the way a CNAME record works?
Is there any other way to achieve my subdomain masking goal?
If you are receiving a DNS_PROBE_FINISHED_NXDOMAIN error, it means one of the subdomains you listed is not resolving to an IP address. I would test both subdomains here -
https://mxtoolbox.com/DNSLookup.aspx
There are a couple important notes here though -
This will only work if the server on domainB has a binding setup for either any (wildcard) domains (usually bad idea), or a binding specifically for your domainA subdomain.
This will only hide your domainB subdomain on a very basic level, if this is what you need. So, in other words, hiding it from non-tech savvy users. It can't be relied upon if security is a concern, since someone could easily find domainB with a DNS lookup.
To truly mask the 'origin' server, you'd need to implement a proxy. This could either be done by making the requests on your domainB server itself, or by using serverless tech (such as Cloudflare Workers, AWS Lamba, etc.). However, this still won't prevent people making requests directly to domainA if they do discover it.

Redirect subdomain on CloudFlare to Google Calendar

I want to redirect a subdomain of a domain I have on CloudFlare, to a Google Calendar (HTML/embed version).
I assumed I needed to use Page Rules to do this, which I have done by following CloudFlare’s documentation. However just following these instructions did not work for me. Apparently I need to add the subdomain to my DNS records on CloudFlare, but I don’t know how to set this up correctly since I have no server or IP to point it to (or I’m just confused as to why I need to even point it to something when I just want to forward a URL).
As mentioned I have no server to point it to – and thus can’t use a .htaccess solution – so don’t know what record type I should be using to use to just have the redirect working
I've had some success just using google.com as the CNAME record, then using a Page Rule to redirect everything on that domain. Because CloudFlare changes the DNS entry to its servers anyway (when you do the orange cloud thing) nobody will know.
I don't know if you could do that directly from cloudflare, but you can solve this using your hosting.
Point subdomain to your hosting server sub IN A 1.2.3.4 via cloudflare
Create sub.domain.com on you hosting
Place redirection script in index file in subdomain sub.domain.com document root:
<?php
header( "Location: http://docs.google.com/your-url-and-so-on" ) ;
?>
"subdomain to my DNS records on CloudFlare, but I don’t know how to set this up correctly since I have no server or IP to point it to"
This doesn't make much sense. A subdomain has to point to a record of some sort (A record or CNAME), so the subdomain wouldn't resolve without a record type of some sort. In order for a PageRule to work, two things have to happen:
The record has to be in your DNS settings.
The record has to have our proxy running over it.
It might be easier to figure out with the actual subdomain in question & what you're trying to forward to specifically.
So CloudFlare does support this through PageRules, you just need to get the URL correct.

Use htaccess mod_rewrite to hide domain name

I've read lots about what can be done with mod_rewrite but I haven't found one to solve my problem. Maybe it can't be done?
I have a sub-domain on my primary domain that I have a customer direct user to to use one of my programs. The customer doesn't want his customers to see that that are on my domain and he doesn't want to use an iframe.
So, is it possible for the user to only see www.subdomain/program.php instead of www.subdomain.mydomain.com/program.php?
If you want the browser to show www.subdomain/program.php in its location bar, you need to register the www.subdomain domain name. There is no way to remove bits of the domain name using anything in the htaccess file. For example, if you've registered example.com and you have a server at foo.example.com, and you want to be able to go to http://foo/some/path/index.html, you're out of luck because the browser is going to attempt to do a DNS lookup of foo and it will most likely fail unless there happens to be a "foo" server under the DNS search domain. Browsers put a great deal of effort to prevent spoofing of the domain name, since it would be really bad if I was able to spoof my website to show the domain of a bank in a browser's location bar while actually visiting an entirely different website.

How will a CNAME DNS affect Google Engine

I'm hosting a clients site at client.mysite.com, but my client want to have its own domain, like www.clientsite.com.
With a CNAME configuration, I'll be able to hook my client domain to the content, but... considering I'm still hosting my clients content, which domain will be finally listed on Google with contents of client.mysite.com contents?
a) mysite.com
b) clientsite.com
Thanks for helping.
In the DNS hierarchy, the CNAME resource record will be attached to the clientside.com. A CNAME is simply a reference to the location of that site's A record. With that in mind, I believe mysite.com will be listed as hosting the data.
Does your client want it to appear under his name?
If so, then this should not be solved using DNS (well, not only using DNS).
If your client wants to get the content listed under his domain name, the best way to do this, is to add their name to your server.
Then point client domain name to your server.
The best way to do the pointing (when also considering SEO)
is to make an webforward (301 permanent) from the root, to the www
and make the www subdomain point to the ressource.
(Or vice verca)
IF you are using the example above (webforward on root) you can use a cname instead of an A record to point the domain name. However do not add a cname to the root of a domain (effectively shutting down your domain name).
So-
Short Answer:
client.mysite.com will have the content (also according to google).
Any attempt to obfuscate this is black hat or grey hat ;)
a better way of doing it is to simply setup the clients domain name on your server.
Then point only one hostname to the server. Server host/headers will take care of the rest.
Setup in DNS
# webforward 301 www
www a or Cname to server
Quick rules:
NEVER put Cname on the root of a domain
Only allow 1 hostname to show content (can be done both as explained above via DNS/webforward or via server configurations)

Using DNS to redirect to another URL with a path [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I'm trying to redirect a domain to another via DNS.
I know that using IN CNAME it's posible.
www.proof.com IN CNAME www.proof-two.com.
What i need is a redirection with a path. When someone types www.proof.com, it should take them to to www.proof-two.com/path/index.htm
I know it can be done using Web Server facilities, but I need DNS redirection.
Is this possible?
No, what you ask is not possible. DNS is name resolution system and knows nothing about HTTP.
if you use AWS, a redirect like
mail.foo.com --> mail.google.com/a/foo.com
can be setup as follows:
in s3, create an empty bucket "mail.foo.com"
under Properties -> Static Website Hosting, set "redirect all requests to: mail.google.com/a/foo.com"
in route53, create an A record "mail.foo.com"
enable "alias", and set alias target to the "mail.foo.com" bucket
not a pure DNS solution, but it works ;)
But be aware of, the redirect skips all the URL parameters e.g.: ...?param1=value1&param2=value2
I realize this is an old thread but FWIW, incase someone else is looking for a way to do this.
While dns does not understand the path portion of the url, it will understand subdomains, so instead of:
www.proof.com IN CNAME www.proof-two.com/path/index.htm
You could use:
www.proof.com IN CNAME proof.proof-two.com
then go to wherever you host proof-two.com and set it to point proof.proof-two.com to www.proof-two.com/path/index.htm.
~ there's always more than one way to skin a cat
Some providers allow this but there are no "pure" DNS solutions since DNS doesn't know anything about the protocol you're using and redirects are a feature from HTTP.
For OVH, see : https://docs.ovh.com/gb/en/domains/redirect-domain-name/
You will have to use the control panel to add your redirection. It will update your DNS zone accordingly.
Let's consider you created a redirection from foo.bar.com to foo2.bar.com/path. OVH keeps the url paths and parameters. So if you try to access foo.bar.com/hello?foo=bar, you'll be redirected to foo2.bar.com/path/hello?foo=bar.
I have a personal project that might help you in solving this issue.
It's an open source redirect solution that allows you to redirect your domain just changing your DNS settings. Link of the project: https://redirect.center/.
To redirect www.proof.com to www.proof-two.com keeping the URL parameters, just set your www DNS entry on proof.com:
www.proof.com IN CNAME www.proof-two.com.opts-uri.redirect.center.
Really it's easy with redirect.center
If you want create a CNAME as :
www.proof.com IN CNAME www.proof-two.com/path/index.htm
using redirect.center your CNAME look as canonical mode as:
www.proof.com IN CNAME www.proof-two.com.opts-slash.path.opts-slash.index.htm.redirect.center.
Now if you want redirect to https website you can add this option:
www.proof.com IN CNAME www.proof-two.com.opts-slash.path.opts-slash.index.htm.opts-https.redirect.center.
Now you can create a CNAME with the canonical mode with slash in your destiny page.
To answer the original question, no, what you want is not possible using only DNS (like everyone has stated). In addition to everything mentioned already, another option is to use a URL redirection service. These types of services can enable you to configure many different types of URL redirects depending on your needs. For example:
Forward a domain apex to a www. subdomain or vice versa
Forward a collection of domain names to a single destination (useful for forwarding domain misspellings, old company names, etc.)
Forward specific domain names to deeply linked pages (like what the OP wants)
A service that does this is EasyRedir. Full disclosure: I developed EasyRedir. There are certainly other options out there though, so I encourage you to have a look around.
DNS won't redirect the path portion of a URL, so that won't be possible.
Adding
www.proof.com IN CNAME www.proof-two.com
will direct access to www.proof.com to www.proof-two.com, where you will need to use web server config to direct users to the appropriate page.
A related work concluded all the below:
Problem:
http://a.com/p1/p2.html should go to http://B.com/p1/p2.html
today, but later when configured manually/automatically, the same
http://a.com/p1/p2.html should go to http://C.com/p1/p2.html
Answers:
DNS - converts name to IP address
Though it can do a lot of redirects, always output is IP address
DNS does not understand the path or protocol part of URL, understands domain part only, that is, a.com only is converted to IP address, so when you hit http://a.com/p1/p2.html may be converted to http://152.132.121.11/p1/p2.html
if you configure wrong in DNS, then you will get 152.132.121.11 (not http://152.132.121.11/p1/p2.html), so you would get some 400s error (400, 403, etc.)
Redirection - this is http://a.com/p1/p2.html can be converted to http://b.com/p1/p2.html
All the methods like GET, POST can work, with if any headers and body, but there is a web server is involved, it could be point of failure, so scalability and availability will be key
If you are on AWS, Route 53 -> API Gateway is possible though custom domains, internally using the Cloud front
It is possible with Amazon Certification Manager, AWS Gateway custom domains & Route53, note the us-east-1 restriction on ACM
Hope that helps someone
I will suppose you have this scenario: You have a unique webserver hosting various websites, each one is supposed to be presented by a separated domain:
http://example.com/customer1/website/page1.html
http://example.com/customer2/website/page2.html
so, the page1.html should be served by www.customer1.com and so on.
create a subdomain inside the example.com dns server (your webserver):
customer1.example.com
in your apache virtual server settings, map the subdomain to the directory that contain the web site for your customer #1, like this:
<VirtualHost *:80>
SetEnv PAGE_ID "customer1"
ServerName customer1.example.com
ServerAlias www.customer1.com
DocumentRoot /your/local/path/webserver/customer1
</VirtualHost>
please note the value for "ServerAlias", it is important for the next step-
at this point, you should be able to navigate to your customer1 website by browsing to:
customer1.example.com
In the DNS settings for customer1.com you must make a CNAME record:
CNAME=www
LOCATION=customer1.example.com
Now, you're enabled to use: www.customer1.com.
My solution to this problem was pretty simple and straight forward. All you need is an IIS server running inside the domain.
Setup CNAME in DNS to point to the IIS server, using host names in IIS to resolve several sites on a single IIS server. I'm using the same IIS server to farm out a few sub domains to external sites.
Then in IIS setup setup redirection for that site to go to your offsite site/path, in my case it was our hosted catalog that I wanted catalog.ourdomain.com to go to. From here all the tweaking is done in IIS. Be sure to enable anonymous authentication so traffic will not be blocked.
While as almost everyone stated already - it's impossible using just DNS. As a workaround I would suggest trying NGINX (http://nginx.org/en/docs/http/request_processing.html).
TL;DR - In NGINX you can create multiple virtual servers that can redirect your request based on the server name.
Ex. http://first.my-server.com redirect to place A and http://second.my-server.com redirect to place B, while both share a single physical server.
You can use htaccess rewrite mod, rewrite to the subfolder if the user is requesting one specific domain not the other.
Of course it is possible to redirect, with the following trick:
Create a new standard primary zone
Name it same as the fictive URL that you want to redirect to
Ensure that this fictive name is different than any AD DNS name
Create A record with following entries:
blank.......................A............................ip-addr-2
www.........................A............................ip-addr-2
What we have here is redirection, essentially. A valid URL will resolve based on the existing DNS primary DNS zone. A fictive URL will be redirected to ip-addr-2. What is important is that the name of this entry is blank, so it will fall down to the next entry in the record and redirect to ip-addr-2
Everyone has already stated this, and I just want to give you another option to a service that can help you. www.301redirect.it is a free service that can redirect your domain (with wildcard) to any destination url.
I want to add a disclosure as well: I'm the developer behind this service and there is a other options out there.

Resources