Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

Domain redirect script

Status
Not open for further replies.
Joined
Mar 13, 2005
Posts
4,685
Reaction score
185
Hi, I'm struggling to find a solution - I need a script that will manage domains eg. Domains are pointed to the script via the nameservers, script recognises the domain and forwards it to another site on the same server, mod rewite is used to give the impression that you are at the original URL. Basically it will work like a parking program does.

Does anyone know of anything out there or is anyone capable of doing me one from scratch (PHP Preferred)?

Cheers, Grant
 
its definately doable...

However, you have several things to consider:

1) You will need to setup wildcard virtual hosting on the server (apache etc)
2) You will need to setup wildcard DNS for the domain
3) if you want to use mod_rewrite, then you have to have a script that will edit the .htaccess file and include an entry for every domain you want pointed. mod_rewrite rules are applied BEFORE any PHP is written.

The best option is to use mod_rewrite for each domain. However, if you wanted to use a PHP solution, you could get a script that would check the domain, and then forward the user to a pre-defined destination.

Jee
 
Use Mass virtual hosting, set apache to respond to the single IP that domains will point to. When new domains are added set a symlink from the new domain to the folder holding the site.

eg

real pages are in
/www/content/

Symlinks
/www/www.domain.com > /www/content
/www/www.domain2.com > /www/content

If you have multiple IP's and multiple apache virtual host containers then you can have each IP on the box pointing to a different content folder and the symlinks pointing to whichever content folder you want.
 
Here's the link for mass virtual hosting
Dynamically Configured Mass Virtual Hosting - Apache HTTP Server

which looks a neat way to do it if a bit complicated to set up initially.


If you have access to apache then might it be simple (if a bit cumbersome/bulky) to just add new virtual hosts to the httpd.conf each time and restart apache perhaps once per day (or whatever).

Each virtual host could point to the same data directory.

eg.

NameVirtualHost 111.22.33.44
<VirtualHost 111.22.33.44>
ServerName www.domain1.com
DocumentRoot /www/hosts/www.alldomains/docs
ScriptAlias /cgi-bin/ /www/hosts/www.alldomains/cgi-bin
</VirtualHost>

<VirtualHost 111.22.33.44>
ServerName Welcome to DOMAIN2.COM
DocumentRoot /www/hosts/www.alldomains/docs
ScriptAlias /cgi-bin/ /www/hosts/www.alldomains/cgi-bin
</VirtualHost>

I imagine it would look a bit stupid with 10,000 domains, but I don't know as it is all loaded at start up. It may just take apache a longer time to restart, then be ok.

I do not speak from experience. . .
. . . and on rereading have probably missed the point!

ps. the parking company would be dishing out distinctive content according to the url, so though it may use the same templates, the actual content will be dynamic and url specific?

yesterday
 
Last edited:
or use CNAME records to alias your domain to the other host?

In all these cases you are hoping the site that you are copying doesn't have hard coded urls in it's links or you will lose your alias.

If the site you're pointing to is yours then maybe it consists of a template with a script within it to:
- parse environment variables to determine the request and hostname?
- pull in appropriate content according to the domain and an associated list of keywords related to that domain?

I may be dreaming!

yesterday
 
Last edited:
I'm not sure whether the environment variables would contain enough information to determine the original alias url that was typed in.

yesterday
 
H
If you have access to apache then might it be simple (if a bit cumbersome/bulky) to just add new virtual hosts to the httpd.conf each time and restart apache perhaps once per day (or whatever).

Several reasons why you don't want to do that.

1) The server is down while you're restarting it after adding new hosts.

2) Each virtual host container is examined by Apache at restart, it checks that the domain points to the IP by doing a dns lookup. ie every restart would hammer your dns server 10,000 times. A) it puts strain on your DNS server and B) it means apache will take forever to restart.

If you've got access to IP's and Apache conf then mass virtual hosting is the way to go. (I talk from experience, hosting 20,000 sites on a cluster of web servers)
 
Thanks for the replies chaps, gone slightly over my head so looks like I've got some reading to do :)

Grant
 
Alternatively you can use a mysql virtualhost module to selectively turn on and off virtualhosts quite easily without restarting Apache. You can even use a script on this to auto generate the virtualhost when you get a new domain.
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Featured Services

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Register for the auction
Acorn Domains Merch
MariaBuy Marketplace

Domain Forum Friends

Other domain-related communities we can recommend.

Our Mods' Businesses

Perfect
Service
Laskos
*the exceptional businesses of our esteemed moderators
Top Bottom