htaccess rewrite for paths

Discussion in 'Apache' started by Omzy, Oct 29, 2009.

  1. #1
    I am running Apache on Windows. My DocumentRoot is:

    C:/apache/web sites

    The site is at:

    C:/apache/web sites/mysite/index.php

    In index.php there is a common include file (header.php) with a stylesheet link as follows:

    <link rel="stylesheet" type="text/css" href="styles.css" />

    So far so good. But I have a directory within "mysite":

    C:/apache/web sites/mysite/advertising/index.php

    Again in index.php there is the include file, but obviously the style sheet reference is pointing to the current folder.

    I tried changing the path of the stylesheet link to "/styles.css" and "../styles.css" but this obviously will give the root file an invalid path.

    How can I satisfy both conditions? Do I have to specify a RewriteBase or something?
     
    Omzy, Oct 29, 2009 IP
  2. organicCyborg

    organicCyborg Peon

    Messages:
    330
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just use the absolute URL path to the stylesheet. No need to mess with rewriting paths.

    
    <link rel="stylesheet" type="text/css" href="http://yoursite.com/styles.css" />
    
    Code (markup):
     
    organicCyborg, Oct 29, 2009 IP
  3. Omzy

    Omzy Peon

    Messages:
    249
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well I'm developing this site on localhost, so I need it t work on both localhost and live server.
     
    Omzy, Oct 29, 2009 IP