Defining HTTP_SERVER variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tristanlee85
Forum Contributor
Posts: 172
Joined: Fri Dec 19, 2003 7:28 am

Defining HTTP_SERVER variable

Post by tristanlee85 »

Here is how the variable is setup right now:

Code: Select all

define('HTTP_SERVER', 'http://www.singalongtracks.com');
So, say the user comes to the site via http://singalongtracks.com (no WWW), the next link they click on it going to change everything to http://www.singalongtracks.com since that's how the variable is defined. What I'm looking to do is make the variable dynamic so if the user doesn't type in the www, it doesn't change throughout the site. Also, other domain names link to this same site as well so I can't simply make it add or remove the www depending on the circumstance. I need to set the variable to the domain the user first comes to the site with.

I've moved away from PHP for a while so I'm a bit rusty.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Take a look at $_SERVER["SERVER_NAME"].
(#10850)
Post Reply