Jump to content

is there any php function that can get the domain prefix user has typed?


kee2ka4

Recommended Posts

Hi everyone,

 

I use the following redirect_to($address) function that I use to redirect a user to a page based on the parameter passed. Here is the code:

 

define('WEBSITE', 'http://domain.com/');

function redirect_to($address)
{
   header('location:'.WEBSITE.$address);
 exit;
}

 

I have a another domain name called http://domain.co.uk/ and hence if a user has come to the site using domain.co.uk then I do not want it to change to domain.com. But whenever the redirect_to function runs it loads http://domain.com since I have definted that in the 'WEBSITE' variable.

 

Is there any function in php that can get the main domain name that the user has typed in the URL. I only need the main domain, no subfolders, so i.e. http://domain.co.uk or http://domain.com, whatever the user has typed in the URL when they visited the site.

 

Thanks

Ket

you should always type the session_start() it good code pratice with any programming lanuage......

 

half mesures dont get jobs lol....

 

Actually if you are  using session autostart than putting in session_start() will cause some funky urls occasional and is doing something unneeded so its would be bad programing practice

 

good practice would be knowing your servers config's and using the language to that config you want.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.