My landing page, e.g. tqt.co.uk uses this:
PHP:
Looking for the domain <strong><?php echo htmlentities($_SERVER['HTTP_HOST']);?></strong>?
This discovers the domain, but doesn't store the information and forward to a seperate domain.
This is the script I produced. It works fine, but wb's may be better.
This will automate everything, all you have to do is set the first index file as the home page for all the forwarding domains. Stages 2 and 3 willl need to go in a seperate directory.
1) create a directory on the server and name the following code ‘index.php’, then set this as the home page for any domain you want forwarding.
PHP:
<?php
$url = $_SERVER['HTTP_HOST'];
header("location: http://www.[your generic domain].co.uk/receive.php?d=$url");
die();
?>
2) In a seperate directory, for the generic domain, name the following ‘receive.php’.
PHP:
<?php
session_start();
$domain = $_GET['d'];
$_SESSION['domain']=$domain;
header("location: http://www.[your generic domain].co.uk/");
die();
?>
3) In the same directory name the following ‘index.php’.
PHP:
<?php
session_start();
$domain = $_SESSION['domain'];
session_destroy();
echo "<p style='color:F00'>The domain name $domain may be for sale</p>";
?>
NB: you will need to replace any [your generic domain] with the actual generic domain in the ‘index.php’ and ‘receive.php’ files.
This works with no problems, but seeing other posts in the thread others may be more experienced than me and can produce the same effect with minimal code.
Just to clarify, the above script displays with or without the 'www.' depending on whether or not it is typed in by the visitor when visiting the site. If you need it to always include/exclude the 'www.' then let me know and I'll update it.