www.webdeveloper.com
Results 1 to 4 of 4

Thread: Linking Files

  1. #1
    Join Date
    Nov 2011
    Posts
    82

    Linking Files

    I am having an issue linking my files. I have a 2 web pages, each in it's own folder, called page_a and page_b. I have a header and footer on the root and a css folder with my stylesheet file. In the header I'm obviously calling

    HTML Code:
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
    However, in each index file in folders page_a and page_b, the PHP code to link the header doesn't seem to pull in the style sheet.

    PHP Code:
    include_once('../header.php'); 
    Any thoughts on what's going on? Thanks!

  2. #2
    Join Date
    Oct 2013
    Posts
    421
    Try
    Code:
    <link type="text/css" rel="stylesheet" href="/css/style.css"/>

  3. #3
    Join Date
    Nov 2011
    Posts
    82
    I would have thought the same thing, but it doesn't seem to work. Could it be because it's actually not on the root, but in a sub directory on my server? It's a dev site so all of this is in a folder on my root.

  4. #4
    Join Date
    Feb 2012
    Location
    Tallahassee, FL
    Posts
    280
    Css files are relative to the current directory. You could do something like this:
    Code:
    <?php
    $httpHost = $_SERVER['HTTP_HOST'];
    $urlString = "http://{$httpHost}/";
    ?><link type="text/css" rel="stylesheet" href="<?=$urlString?>css/style.css"/>
    Also, just a tip, I find it is better to set up a subdomain for my dev environment. Like if I am working on:
    http://something.com/
    I'll make a subdomin like:
    http://dev.something.com/

    It makes the scripts act like they will in production

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles