SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru cyjetsu's Avatar
    Join Date
    May 2008
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    relative vs root url paths

    I have a problem. I want to end up with only root path urls in my webpages(eg img src="/images/image.jpg") as opposed to relative paths(img src="../../images/image.jpg"). When browsing my site on the server once, I found lots of extra "///" characters in the address bar which I believe is because I used "../" in my url's, this is one of the reasons I want root paths. And also of course, if I change position of the page in the directory structure, I would have to change all relative paths.
    So why cant I just use root paths? Simply becuase unless I upload it to my server, webpages will not display correctly on my computer becuase I cant set a root directory for my browsers.
    Is there any software I can use to set a pseudo-server on my computer which will set a root directory for all browsers? Or are there any firefox/ie plugins that will accomplish this?
    I was wondering how other designers deal with this issue. Right now I just manually edit the css style and image paths, links to other local pages I leave as root paths, which means I cant browser them unless I upload them to my server.
    I will try writing a script to automatically change all "../../../" in my pages to just "/", which would solve the problem of editing relative to root, but I would still have all the other issues I mentioned above.
    Any ideas are appreciated.

  2. #2
    SitePoint Guru cyjetsu's Avatar
    Join Date
    May 2008
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I forgot to mention absolute paths, if I upload all files to my server I could use an absolute http path for all my links but I am not sure if it is good practice. And also no one would be able to browse the website offline.
    Another question, which paths are best for SEO? Relative, Root, Absolute? Or does it not matter?

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Install a web server onto your computer like Apache, or IIS, or Lighttpd.
    Or can use prepackaged stuff like XAMP or WAMP.

    Then root paths are not much of a problem, esp. if you set up virtual host with Apache and private domain names for them.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Zealot c.t.c.'s Avatar
    Join Date
    Apr 2007
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A prepackaged server configuration sounds best for you. Try WAMP or XAMPP if you're running Windows or MAMP if your on a Mac. Most Linux distros provide a single package to install a LAMP server as well--check the documentation for your distro.

  5. #5
    SitePoint Guru cyjetsu's Avatar
    Join Date
    May 2008
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I installed apache no problem, its great.

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apache has a very useful feature called 'virtual hosts' which allow you to set up multiple websites on the same server. By editing your hosts file you can use different fake domain names for them. For instance, I use autisticcuckoo.dev for the development version on my local machine.
    Birnam wood is come to Dunsinane

  7. #7
    SitePoint Wizard silver trophybronze trophy
    Join Date
    Jul 2008
    Location
    New York, NY
    Posts
    1,432
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I saw this the other night and it seemed interesting:

    http://htmldog.com/reference/htmltags/base/

  8. #8
    SitePoint Guru cyjetsu's Avatar
    Join Date
    May 2008
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. Didn't know about that one.
    I have successfully setup apache with multiple virtual hosts now so that works pretty well. Apache is awsome!

  9. #9
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought <base> tags became extinct in the '90s.
    Birnam wood is come to Dunsinane

  10. #10
    SitePoint Wizard silver trophybronze trophy
    Join Date
    Jul 2008
    Location
    New York, NY
    Posts
    1,432
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    I thought <base> tags became extinct in the '90s.
    hehe - early 90's probably. I have not heard of anyone actually using this process.

    1. Only applies to one specific path for every applied image on the page.

    2. It is as bad as this:

    <blink><p><div><h1>Hello World</h1></div></p></blink>

    Well maybe not that bad but still...


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
  •