Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect siteA to siteB with A or CNAME records [closed]

I have 2 hosts and I would like to point a subdomain on host one to a subdomain on host two:

subdomain.hostone.com --> subdomain.hosttwo.com

I added a CNAME record to host one that points to subdomain.hosttwo.com but all I get is a '400 Bad Request' Error.

Can anyone see what I'm doing wrong?

like image 341
Peter Coulton Avatar asked Aug 19 '08 14:08

Peter Coulton


People also ask

Can you redirect with a CNAME?

A CNAME record redirects site visitors from the domain name they entered in their browsers to another domain name—in your case, your website running on Site Factory. Using CNAME to point to a website location instead of an actual IP address also allows Site Factory to better guarantee high-availability.

Can you redirect with an A record?

For any redirects that point outside of your FQDN, you need to use a special kind of DNS record called an HTTP Redirection record. These records are actually an A record that points to a dedicated web server containing the 301 redirect to the external FQDN.

What is the difference between a CNAME and a redirect?

The main difference between CNAME and other redirects is that CNAME is just a DNS record type (similar to A, TXT and other DNS level records) while 301, 302 redirects and URL frames are hosting server-powered redirects.

What DNS record is a redirect?

The A , CNAME , and ALIAS records cause a name to resolve to an IP. Conversely, the URL record redirects the name to a destination. The URL record is a simple and effective way to apply a redirect for one name to another name, for example redirecting www.example.com to example.com . The A name must resolve to an IP.


3 Answers

Try changing it to "subdomain -> subdomain.hosttwo.com"

The CNAME is an alias for a certain domain, so when you go to the control panel for hostone.com, you shouldn't have to enter the whole name into the CNAME alias.

As far as the error you are getting, can you log onto subdomain.hostwo.com and check the logs?

like image 66
Eric Z Beard Avatar answered Oct 08 '22 20:10

Eric Z Beard


I think several of the answers hit around the possible solution to your problem.

I agree the easiest (and best solution for SEO purposes) is the 301 redirect. In IIS this is fairly trivial, you'd create a site for subdomain.hostone.com, after creating the site, right-click on the site and go into properties. Click on the "Home Directory" tab of the site properties window that opens. Select the radio button "A redirection to a URL", enter the url for the new site (http://subdomain.hosttwo.com), and check the checkboxes for "The exact URL entered above", "A permanent redirection for this resource" (this second checkbox causes a 301 redirect, instead of a 302 redirect). Click OK, and you're done.

Or you could create a page on the site of http://subdomain.hostone.com, using one of the following methods (depending on what the hosting platform supports)

PHP Redirect:


<?
Header( "HTTP/1.1 301 Moved Permanently" ); 
Header( "Location: http://subdomain.hosttwo.com" ); 
?>

ASP Redirect:


<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://subdomain.hosttwo.com"
%>

ASP .NET Redirect:


<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://subdomain.hosttwo.com");
}
</script>

Now assuming your CNAME record is correctly created, then the only problem you are experiencing is that the site created for http://subdomain.hosttwo.com is using a shared IP, and host headers to determine which site should be displayed. To resolve this issue under IIS, in IIS Manager on the web server, you'd right-click on the site for subdomain.hosttwo.com, and click "Properties". On the displayed "Web Site" tab, you should see an "Advanced" button next to the IP address that you'll need to click. On the "Advanced Web Site Identification" window that appears, click "Add". Select the same IP address that is already being used by subdomain.hosttwo.com, enter 80 as the TCP port, and then enter subdomain.hosttwo.com as the Host Header value. Click OK until you are back to the main IIS Manager window, and you should be good to go. Open a browser, and browse to http://subdomain.hostone.com, and you'll see the site at http://subdomain.hosttwo.com appear, even though your URL shows http://subdomain.hostone.com

Hope that helps...

like image 11
Brian G Swanson Avatar answered Oct 08 '22 20:10

Brian G Swanson


It sounds like the web server on hosttwo.com doesn't allow undefined domains to be passed through. You also said you wanted to do a redirect, this isn't actually a method for redirecting. If you bought this domain through GoDaddy you may just want to use their redirection service.

like image 2
Nick Berardi Avatar answered Oct 08 '22 21:10

Nick Berardi