SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    London, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    css and subdomains

    Is there a way to link to the same css file from different subdomains? If so can someone please explain how this can be done?

    If not, does anyone know how i can use php to detect the subdomain and therefore use it to print a path for the css file to be accessed.

    Im not too good with php, so if you could throw me some code it would be much appreciated.


    Thanks.

  2. #2
    SitePoint Wizard Ian Glass's Avatar
    Join Date
    Oct 2001
    Location
    Beyond yonder
    Posts
    2,384
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd just use the full path for the stylesheet link. For instance, assume you have this page on your first subdomain:
    Code:
    <!-- ... HTML CODE ... -->
      <head>
        <title>Page on SubDomain.Example.com</title>
        <link type="Stylesheet" type="text/css" href="http://example.com/styles.css" />
      </head>
    <!- ... HTML CODE ... -->
    'You get it? :-)

    ~~Hope This Helps

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    London, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah thanks for the suggestion... but that doesnt really work... the problem is that when i do that, my scrollbar colors dont change. However if i link using an relative path... then the scrollbars do change color. Maybe im missing something?

    After teaching myself how to grab the subdomain using php... i realised i still cannot link the the css file using a relative path (yes i know im a dumbass, please dont rub it in).

    Anyone else got any ideas how i can solve this?

  4. #4
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If it's a subdomain, then isn't the subdomain just a folder under the root of the site? You know, like
    Code:
    /site.com
      /folder1
        /sub-folder1
        /sub-folder2
        /etc.
      /folder2
      /folder3
    So then wouldn't http://folder1.site.com go to the directory named folder1 on the site? Am I making any sense here, or am I just talking in circles?

    Also, check your DOCTYPE in regards to the scrollbar colors displaying. I know that IE6 won't display custom scrollbar colors when a strict DOCTYPE is used.

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    London, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, using colon's info and something i personally assumed wouldnt work... i got it working (thanks colon!). Assuming my CSS file URL is http://www.domain.com/css/main.css, Im using the following php code to set a relative path for the css file:
    PHP Code:
    $a explode("."$HTTP_HOST);
    $sub $a[0];
    if (
    $sub == www) {
    echo (
    "/css/main.css");
    } else {
    echo (
    "../css/main.css");

    <EDIT>
    Nope, its not working... i had just refreshed the wrong page..lol

    Still open to suggestions
    </EDIT>
    Last edited by Shaq; Mar 24, 2002 at 06:10.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •