AutoChoosing a CSS file based on URL


Posted on 16th Feb 2014 07:03 pm by admin

Hey everyone,

I have a site that has multiple URLs and CSS files.

Based on the URL that the user goes to I want that CSS file to load.

This is what I have thus far in the <head> of my HTML/PHP file: index.php
Code: <!-- ====================================================== -->
<!-- Which CSS template to use? It depends on the site URL. -->
<!-- ====================================================== -->

<?php $site = $_SERVER['SERVER_NAME']; ?>

<!-- ====================================================== -->
<!-- ============== Harvest Auction Domains =============== -->
<!-- ====================================================== -->
<?php if ($site = "www.agcooponline.com") { ?>
<link href="../templates/tsgcalpha/css/harvestauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>
<?php if ($site = "www.agliberty.com") { ?>
<link href="../templates/tsgcalpha/css/harvestauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>
<?php if ($site = "www.harvestauction.com") { ?>
<link href="../templates/tsgcalpha/css/harvestauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>
<?php if ($site = "www.harvestauction.net") { ?>
<link href="../templates/tsgcalpha/css/harvestauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>
<?php if ($site = "www.harvestauction.org") { ?>
<link href="../templates/tsgcalpha/css/harvestauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>
<?php if ($site = "www.harvestauction.biz") { ?>
<link href="../templates/tsgcalpha/css/harvestauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>
<?php if ($site = "www.harvest2market.com") { ?>
<link href="../templates/tsgcalpha/css/harvestauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>

<!-- ====================================================== -->
<!-- ============== Hobbies Auction Domains =============== -->
<!-- ====================================================== -->

<?php if ($site = "www.hobbiesauction.com") { ?>
<link href="../templates/tsgcalpha/css/hobbiesauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>

<!-- ====================================================== -->
<!-- ============== Tools Auction Domains ================= -->
<!-- ====================================================== -->

<?php if ($site = "www.toolsforauction.com") { ?>
<link href="../templates/tsgcalpha/css/toolsforauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>
<?php if ($site = "www.tooleagle.com") { ?>
<link href="../templates/tsgcalpha/css/toolsforauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>
<?php if ($site = "www.tooltwister.com") { ?>
<link href="../templates/tsgcalpha/css/toolsforauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>

<!-- ====================================================== -->
<!-- ============== Aviation Auction Domains ============== -->
<!-- ====================================================== -->

<?php if ($site = "www.aviatorsauction.com") { ?>
<link href="../templates/tsgcalpha/css/aviatorsauction.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>

</head>
However when I go to any of the URLs it always sees www.aviatorsauction.com.

I have used both $_SERVER['SERVER_NAME']; and $_SERVER['HTTP_HOST'];

Any help would be greatly appreciated.

Thank you

No comments posted yet

Your Answer:

Login to answer
170 Like 40 Dislike
Previous forums Next forums
Other forums

help with contest script
I would like to code a contest script to my site but i don't know how. Could someone just give me pu

email CODING Problem
Email coding problem.

I need to send a section of the info to $tf and the same as a Cc to $em

HTML Viewer HIDE scrollbar
How can I disable scrollbars in a HTML Viewer control? I can't hide them. Even i have enough space b

need help with mail()
hi i want to send an email with attaching pdf file using php. i have the following script but the pr

MySQL query problem
When I try to run the following piece of code, I get this error:
QuoteWarning: mysql_query(): sup

Is this Safe or Unsafe?
Hi i made a few pages with lots of peoples help now i just want to know if they are safe or not can

Supress some serveroutput but not all
Hi,

I have a script I'm working on that uses plsql to create and RMAN script, this uses d

How to copy a part of a vector in a raw memory
Hi,

How can I copy a part of a vector into a memory:

1
2
3
4
5

TabControl Inside ListView Not Editing
Hello everybodyI have a ListView on my page. Inside the ListView I put a TabControl, cuz I want to p

Converting numbers to months
The porgram works -just need the last function(month_convert_ to convert numbers to months -thanks.

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash