SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: base url

  1. #1
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    base url

    Hi there,

    I've had a search through this forum, and I'm sure this question's been asked before, but I can't seem to find a satisfactory answer.

    I'm testing out a site here:
    http://www.mikes-lab.com/luxe/

    Now in my HTML I have links like this <img src="/images/blahblah.jpg">, which ain't workin, cos the server is looking in mikes-lab.com/images/, not mikes-lab.com/luxe/images.

    So I've tried using <base href="http://www.mikes-lab.com/luxe/"> in the head, but no joy.

    I've also added a .htaccess file to /luxe/ and added the command:
    DocumentRoot /path/to/public_html/luxe/

    and I get a 500 Internal Server Error.

    I've also tried
    RewriteEngine on
    RewriteBase /luxe/

    no good.

    Does anyone have any idea where I'm going wrong?

    Cheers,
    Mike

  2. #2
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ok, so after a bit of playing around, I realised that the trailing slash was messing me around.

    The base href has a trailing slash on it http://mikes-lab/luxe/
    The links in my html were like so /css/styles.css, which was pointing to the root directory, I tool the leading slashes out and now everything works... except one thing. References in my stlye sheets aren't loading. They are relative (../images/image1.jpg), and don't want to play with me.

    Stumped.

  3. #3
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,838
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by mickyginger View Post
    Ok, so after a bit of playing around, I realised that the trailing slash was messing me around.

    The base href has a trailing slash on it http://mikes-lab/luxe/
    The links in my html were like so /css/styles.css, which was pointing to the root directory, I tool the leading slashes out and now everything works... except one thing. References in my stlye sheets aren't loading. They are relative (../images/image1.jpg), and don't want to play with me.

    Stumped.
    Your supplied link to Mikes-Lab/luxe is missing .com

    For your stylesheet try this:

    PHP Code:

    <link rel="stylesheet" href="../css/styles.css"
    With a little bit of luck your stylesheet image references should be correct
    Last edited by John_Betong; Feb 16, 2012 at 09:50. Reason: spelling not my forty :)
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014

  4. #4
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi John_Betong,

    Thanks for your reply.

    Yeah, my bad about the .com, that was a typo.

    <link rel="stylesheet" href="../css/styles.css">
    references the stylesheet at www.mikes-lab.com/css/styles.css, rather than www.mikes-lab.com/luxe/css/styles.css

    I'll keep digging.

  5. #5
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    D'oh!

    Just realised I hadn't uploaded the images!

    Feel like an absolute noob.

    Ok, so just to clarify, if anyone comes a-looking at this post in the future, I've set up the head like so:
    Code:
    <head>
      <base href="http://www.mikes-lab.com/luxe/">
      <link rel="stylesheet" src="css/styles.css">
    </head>
    and everything works a charm.



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
  •