there is no such variable,
I think you should cut off the "www." in the code.
Main Topics
Browse All TopicsIm want to verify the domain name where my scripts are running
what I started with is
$_SERVER['HTTP_HOST']
the problem with this is that the result could be www.domain.com or domain.com
where I would like it to be domain.com always at all times only because I will be comparing the domain name with a field in the database to verify if they are allowed to be using my application anyone knows if there is a predefined variable for this or do i have to cut off the www. in code ?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
there is no such variable,
I think you should cut off the "www." in the code.
Just simply use
$domain = str_replace("www.","",$_SE
Problem with str_replace is if your domain is something like 'mysiteonwww.com', you'll come away with just 'mysiteoncom'
if there's no www, no problem.
The below will return 'domain.com' for all of the following:
www.domain.com
domain.com
subdomain.domain.com
www.subdomain.domain.com
$domain = preg_replace("/^(.*\.)?([^
So, you only want to cut off "www." if "www." is at the beginning?
That's an easy one:
<?php
$_domains = array(
"www.domain.qc.ca",
"www.domain.com",
"www.subdomain.domain.com"
"domain.qc.ca",
"www.domain.org",
"domain.org",
"subdomain.company.com",
"mysiteonwww.com",
"www.mysiteonwww.com",
"www.www.com"
);
foreach ($_domains as $_domain) {
echo preg_replace("/^www\./", "", $_domain);
echo "<BR>\n";
}
?>
--brian
$subject="http://www.exper
if (preg_match('/\\b(https?|f
$result = $regs['domain'];
}
echo($result);
Business Accounts
Answer for Membership
by: snoyes_jwPosted on 2006-03-29 at 07:32:42ID: 16322604
Nope, I think you have to cut it off in the code.
$domain = preg_replace("/^www\./", "", $_SERVER['HTTP_HOST']);