Jump to content

[SOLVED] Accessing Url Information(Domain Name)


Finalfantasykid

Recommended Posts

I have a site which has 3 domains, but I want a separate skin for each one.  Each domain is sharing the same files and databases, so what I need to do is have some way for my index.php file to see which domain it is at, that way I can change which images and css file the site is using.

 

Or is there another code which does the same thing, like javascript?

Link to comment
Share on other sites

wait, lol do it like this:

 

<?php
$url = $_SERVER["HTTP_HOST"];
if ($url == ("domain.com")){
$css = 'style1.css';
}else{
if ($url == ("domain.net")){
$css = 'style.css';
}
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo $css; ?>"/>

Link to comment
Share on other sites

wait, lol do it like this:

 

<?php
$url = $_SERVER["HTTP_HOST"];
switch ($url)
  {
    case "domain.com":
      $css = 'style1.css';
      break;
    case "domain.net";
      $css = 'style.css';
      break;
    default:
      $css = 'style.css'; # I realise that the above and this one are the same, but I'm allowing for more domains.
  }
?>
<link rel="stylesheet" type="text/css" href="<?=$css; ?>"/>

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.