I'm trying to foward some domains to another. The scenario is quite easy:
domain example.com is the primary domain
the domain example.net should be forwarded to example.com
all set up subdomains should be as well
As a DNS, my machine is running bind
and my configs look like this:
named.conf:
zone "example.com" {
type master;
file "/etc/bind/db.example.com";
notify yes;
allow-transfer{
208.79.240.3;
208.79.241.3;
};
};
zone "example.net" {
type master;
file "/etc/bind/db.example.net";
notify yes;
allow-transfer{
208.79.240.3;
208.79.241.3;
};
};
db.example.com:
$TTL 1d
@ IN SOA ns.example.com. dns.example.com. (
2012021204 ;serial
8H ; refresh
2H ; retry
4W ; expire
1D) ; minimum
IN NS ns
IN NS ns1.rollernet.us.
IN NS ns2.rollernet.us.
ns IN A 78.46.106.248
ns1.rollernet.us. IN A 208.79.240.3
ns2.rollernet.us. IN A 208.79.241.3
@ IN MX 10 mail
@ IN MX 100 mail.rollernet.us.
@ IN MX 100 mail2.rollernet.us.
@ IN A 78.46.106.248
mail IN A 78.46.106.248
www IN A 78.46.106.248
db.example.net
$TTL 1d
@ IN SOA ns.example.net. dns.example.net. (
2012021208 ;serial
8H ; refresh
2H ; retry
4W ; expire
1D) ; minimum
IN NS ns.example.com.
IN NS ns1.rollernet.us.
IN NS ns2.rollernet.us.
ns IN A 78.46.106.248
ns1.rollernet.us. IN A 208.79.240.3
ns2.rollernet.us. IN A 208.79.241.3
@ IN A 78.46.106.246
mail IN CNAME mail.example.com.
www IN CNAME www.example.com.
The forwarding works fine so far and all access to (www.)example.net is forwarded to (www.)example.com.
The only thing I am missing is that the address bar in my browser is not switching to (www.)example.com when I'm accessing (www.)example.net. How can I make this happen?
If you want to simply go to the same IP address, then a simple CNAME will suffice.
But I gather you want to actual redirect, so you will have to use http redirect. Through Bind/dns redirect is not possible.
Since this is a simple catch all redirect then with apache it is a simple as these couple of lines:
Not via DNS. What you want is a URL redirect, possibly via HTTP.
You can't.
If both domains need to end up at the same machine, then both domains need to contain identical A records for their respective labels.
If the data in the zone file is all relative, you can use the same zone file for both zones.