Web Hosting Talk







View Full Version : Need code to identify domain on Apache/Cpanel shared hosting


warrenz
08-26-2008, 10:05 PM
I want my clients to go to the Awstats tool directly rather than logging into cpanel then opening the script. For some, I have manually copied the URL then place it in a meta refresh tag of an index.php file and placed the file in a folder called stats.

For each I use the same URL but change the domain to match. This method is quite tedious so I want to use PHP to identify each client's domain, just cannot find the solution. Can anyone assist with this? thanks

This is what I currently use
<?php
echo "<meta http-equiv='refresh' content='0; URL=http://myhosting.com:2082/awstats.pl?config=website.com'>"
?>

This is what I vision
<?php
echo "<meta http-equiv='refresh' content='0; URL=http://myhosting.com:2082/awstats.pl?config=['Domain']'>"
?>

larwilliams
08-26-2008, 11:12 PM
here's a better version of that code:


<?php
print header("Location: http://myhosting.com:2082/awstats.pl?config=website.com");
exit;
?>

vibrokatana
08-27-2008, 08:40 AM
Assuming they are requesting the page from their domain:


<?php
print header("Location: http://myhosting.com:2082/awstats.pl?config=" . $_SERVER['HTTP_HOST']);
exit;
?>

warrenz
08-27-2008, 01:24 PM
Thanks both for the suggestion and solution.