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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.