View Full Version : Domain Forwarding
webfors 12-05-2000, 11:35 AM Hi everyone,
I know this should most likely go in the software section but...
Ok, what DNS entry do I need to make to point a domain to an external (not on my server) url like http://somedomain.com/username/
An A record doesn't cut it and I'm wondering what dns entry would need to be made in the zone file, or if it can be done at all.
Any help would be appreciated.
[Edited by tabernack on 12-05-2000 at 11:14 AM]
webfors 12-05-2000, 12:19 PM Anyone?
eva2000 12-05-2000, 02:45 PM a CNAME entry ?
Patience, Tabs... You only waited an hour! :D Should probably allow 24 hours max for it.
Eva2000 is correct - use a CNAME entry to re-direct to an external domain/subdirectory/whatever.
webfors 12-06-2000, 12:17 AM Hi BC, :)
Sorry, I was impatient for an answer this morning and I saw my post getting buried. :D
SO, a CNAME record will allow you to redirect to a domain.com/subdirectory? I was under the impression that there was no way to do this via DNS. I did it using a redirect java script in the index.html of that domains account, but that means I have the overhead of the account (which I want to avoid).
I'm going to try this now.
webfors 12-06-2000, 12:17 AM PS: Is the email notification turned OFF!
I don't get any emails notifying me of replies.
kunal 12-06-2000, 12:21 AM hmmm... I think the mail function is messing around.. hmm
eva2000 12-06-2000, 12:23 AM nope, i get my email notifies :)
cnames works cause i know that's how everyone.net offer's it free web mail service :D
for my 4webspace.com server, right now i am waiting on my nameservers to register and for my domains to propogate - i hate the waiting :(
webfors 12-06-2000, 12:48 AM AHHHHHHHHHh,
ok, I have tried every possible combo and it doesn't work for subdirectories of a domain. I can get it to point to somedomain.com but not to somedomain.com/user/
Any ideas?? Can you post a sample CNAME entry? I think this may not be possible via dns.
[Edited by tabernack on 12-05-2000 at 11:51 PM]
webfors 12-06-2000, 12:52 AM Eva,
How's the speed of the server? Got an ip for as to look at? :)
Did you find out if you're on a capped line or is it burstable?
bdraco 12-06-2000, 12:56 AM Actually CNAME entries only allow you to alias a domainname to another domain name. You have to have something to actually handle the redirection. This can be solved with the setup below. The ip address should be the ip address from the A entry of the domain or the ip address of the CNAME the domain is pointing too.
(you will probably want to view source, and copy the perl script that way so it gets aligned right)
Nick
Setup a VirtualHost in your httpd.conf
<VirtualHost [ip address of dns entry here]>
ServerName [ip address of dns entry here]
DocumentRoot /[home/somewhere/public_html]
ServerAdmin [you@yourdomain.com]
DirectoryIndex domainredirect.cgi
</VirtualHost>
Then put the below script in the dir which you set to be the document root. make sure to chmod it 755.
You will need to fill in the two config varibles
here is a sample domainmap file
------------begin domainmap--------------------------------
darkorb.net=http://www.vdi.net/cows/
*.vdi.net=http://www.vdi.net/redirected/
-----------------------------------------------------------
-----------------begin domainredirect.cgi------------------
#!/usr/bin/perl -T
#################################################
# Domain Redirector #
# (c) 2000 DarkORB Communications Inc. #
# #
# Version 0.1 - December 05, 2000 #
# This code is subject to the artistic license #
#################################################
use strict;
#################################################
# #
# Config #
# #
#################################################
# domainmap - this is a file that contains a #
# database of domains and the url #
# that they should get redirected #
# too. #
# Sample domainmap file (regexs are ok): #
# darkorb.net=http://www.vdi.net/~darkorb/ #
# *.cpanel.net=http://www.darkorb.net/cpanel3 #
#################################################
my($domainmap) = '/home/you/domainmap';
#################################################
# unknowndomain - this is a url to a page tha #
# the user will end up at if #
# the domain is not in the #
# domainmap #
#################################################
my($unknownpage) = 'http://www.yourisp.com/domainnotknown.html';
#################################################
# DO NOT MODIFY BELOW THIS LINE UNLESS YOU KNOW #
# WHAT YOU ARE DOING :-) #
#################################################
my($host) = $ENV{'HTTP_HOST'};
$host =~ s/[\n|\r]*//g;
if ($host eq "") { unknowndomain(); }
open(DMP,$domainmap);
while(<DMP>) {
s/[\n|\r]*//g;
my($match,$url) = split(/=/, $_);
if ($host =~ /^${match}/) {
print "Location: " . $url . "\n\n";
exit;
}
}
close(DMP);
unknowndomain();
sub unknowndomain {
print "Location: " . $unknownpage . "\n\n";
exit;
}
------------------------------------------------------------
eva2000 12-06-2000, 01:06 AM Originally posted by tabernack
Eva,
How's the speed of the server? Got an ip for as to look at? :)
Did you find out if you're on a capped line or is it burstable? the 4webspace.com raq3 server is a pretty fast machine for 32MB - but there ain't any live sites with traffic on it yet :)
i created new nameservers for the server to run my own dns and changed my domain's dns to point to the new nameserver so i have to wait a few days for things to resolve :(
i am finding ftp, and telnet to the server delayed and slow, but that's probably cause i am using the ips to telnet and ftp and i have reverse dns lookup turned on (domains and nameserver ain't ready yet)
webfors 12-06-2000, 01:07 AM That's what I thought bdraco. I used the following setup to get the same solution. Tell me what you think. I just created the account with my CP (much easier than diving into httpd.conf. I like to do that as little as possible). Then I just created the following index.html file in the web root:
<html>
<head>
<title>Redirect</title>
<script>
timerID=setTimeout('change()',0)
</script>
<script>
function change()
{
location.replace('http://www.somedomain.com/somedirectory/');
}
</script>
</head>
</body>
</html>
Works great and it's seamless.
bdraco 12-06-2000, 01:13 AM The point of the perl script was that you could point any amount of domains at it and just edit the domainmap file. As for your javascript. Why not try something like this.
<html>
<head>
<title>Redirect</title>
<script>
window.location.href = "http://someurl";
</script>
</head>
<body bgcolor=#FFFFFF>
<a href="http://someurl">Click here if you are not automaticlly redirected in 5 seconds</a>
</html>
</html>
webfors 12-06-2000, 01:44 AM Ok,
I like that idea better (keeping all these domains in one file), but I don't like the extra step of having to manually define DirectoryIndex in httpd.conf.
What are the chances of a browser not reading Javascript nowadays?
[Edited by tabernack on 12-06-2000 at 12:59 AM]
|