www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: more on relative vs absolute paths

  1. #1
    Join Date
    Jun 2004
    Location
    Tampa, Florida
    Posts
    77

    more on relative vs absolute paths

    Maybe this is not a problem with other HTML editors, , if not please let me know, as I'm still using the old HOMESITE editor.

    I like to use relative paths, mainly so I can test my site locally with browsers on my file system, and also because absolute paths to graphics has in one instance caused my hosting company a lot of grief (I'll skip the details unless someone is interested).

    So when I'm developing, it would really be nice if I could still use the "root" (/) as a starting point. That way, for example,, wherever a page ends up in a directory tree, a <link> tag like this will always work...

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

    But of course that won't work when testing on my home computer. Is there a workaround for this? Is there a way to tell Homesite that when interpreting links, "/" should refer to the project root? If not, would Coffeecup be able to do this? I don't think I can use "./" as a substitute, can I?
    Randy (PeterPan)
    * * *
    * *
    ... Second Star to the Right, and Straight on Till Morning!
    * * *

  2. #2
    Join Date
    Oct 2013
    Posts
    486
    You can use ../

    For example, if your referring page is at /stuff/morestuff/index.htm you would use
    Code:
    <link rel="stylesheet" type = "text/css" href="../../styles/myStyles.css" >

  3. #3
    Join Date
    Jun 2004
    Location
    Tampa, Florida
    Posts
    77
    Yeah thanks. I do that a lot, and in fact the editor usually does that for me pretty well. But of course being able to start from the project root would be ideal. If there's no other way, i can live with it.
    Randy (PeterPan)
    * * *
    * *
    ... Second Star to the Right, and Straight on Till Morning!
    * * *

  4. #4
    Join Date
    Oct 2013
    Posts
    486
    Unless you put your local files at the root of the drive that's your only choice. I've thought about using a thumbdrive for website development simply because of that. But it means keeping track of that drive, making sure it's plugged in when I need to work on a site, etc. etc. So far, not worth the effort. Although it might be worth the effort to have local website files on a dedicated partition.
    Last edited by Kevin2; 01-09-2014 at 02:25 PM.

  5. #5
    Join Date
    Jun 2004
    Location
    Tampa, Florida
    Posts
    77
    Kevin: Yeah that's a really good idea!!! I never thought of that! I don't know if I'd want to use a thumb drive either, but either a small partition on my main drive or a secondary drive would solve this issue for good!

    Thanks!!!
    Randy (PeterPan)
    * * *
    * *
    ... Second Star to the Right, and Straight on Till Morning!
    * * *

  6. #6
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    / = root
    ./ = current working path where html document is saved
    ../ = move up one directory

    Using relative paths should not pose a problem in any editor, the only editor that I found was a royal pain in the rear was the Adobe Indepth which insisted on writing in javascript and fixing paths so it was an absolute path.

    Your testing server... What are you using?
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  7. #7
    Join Date
    Jun 2004
    Location
    Tampa, Florida
    Posts
    77
    Mr :\\127.0.0.1 (can i call you loopback for short ;-) By hosting server has no problem with any of those constructs. Its just that when testing code in my own machine, any link that starts with a root "/" will try to go to the root of my "C:\" drive, instead of the root of my project. This is all static page development, so there really is no server involved... just a browser.
    Randy (PeterPan)
    * * *
    * *
    ... Second Star to the Right, and Straight on Till Morning!
    * * *

  8. #8
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    That is why I asked if you have a server on your PC for proper testing. If not then I can suggest that you try something like XAMPP which you can get from portable Apps which is a system that allows you to install and run from a *USB drive / flash drive / thumb drive / stick drive and test in a proper web based environment that you can refer to in a web browser by IP address or the loopback name.

    If you edit your local hosts file, you can add in a name and point it to 127.0.0.1 and end up with http://testing/ for example

    your hosts file is found in %windir%\system32\drivers\etc\hosts

    copy %windir%\system32\drivers\etc\hosts and open a run dialog and paste, hit return and select notepad to open the file then you will see something like...
    Code:
    # Copyright (c) 1993-1999 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    #      102.54.94.97     rhino.acme.com          # source server
    #       38.25.63.10     x.acme.com              # x client host
    
    127.0.0.1	localhost
    after 127.0.0.1 localhost on a new line put
    127.0.0.1 testing

    then save the file, close and then you will have a URL for http://testing/ that will open up the root page for your installed server (obviously when you have your server installed!)

    So... go here http://portableapps.com/ and grab the installer for the portable apps program and then go here http://portableapps.com/apps/development/xampp and grab XAMPP, install and then run, the server will then respond to http://testing/ when you request it in a web browser.







    * delete as required
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  9. #9
    Join Date
    Mar 2012
    Posts
    1,528
    One way to have project-specific root directories is to install multiple instances of a localhost. I use wampserver installed on a network file server, and separately on the local workstation, but you could have multiple instances on your workstation. Each instance points the localhost root (http://127.0.0.1 otherwise known as http://localhost) to the \www\ directory in ...\wamp\ directory you installed wamp into. So you can have, say, C:\project1\wamp\www\... and C:\project2\wamp\www\... etc... So, depending upon which instance you have running, localhost will point to a different root. However, I'm no sure what would happen if you tried running multiple instances simultaneously on a single workstation.

    If you need to work on multiple projects simultaneously, you would need to have multiple servers on your LAN, with one localhost on each. That is not as expensive as it may sound, I use a spare 10 inch netbook computer as a network file server. Throughput and disk capacity is not an issue.

  10. #10
    Join Date
    Mar 2012
    Posts
    202
    If you don't want to install a server and don't want to use a flashdrive, you can use the "subst" command in Windows to associate a new virtual drive to an existing path on the local machine. Open a command prompt and type the following to create a new X: drive for the path C:\WebFiles

    Code:
    subst X: C:\WebFiles
    If you ever need to delete the virtual drive, type the following:

    Code:
    subst /D X:

  11. #11
    Join Date
    Mar 2012
    Posts
    1,528
    Quote Originally Posted by Gray1989 View Post
    If you don't want to install a server and don't want to use a flashdrive, you can use the "subst" command in Windows to associate a new virtual drive to an existing path on the local machine.
    That takes me back. I did not know that old MSDOS command still works! If so, it is a far simpler solution.
    Last edited by jedaisoul; 01-10-2014 at 08:26 AM.

  12. #12
    Join Date
    Mar 2012
    Posts
    202
    Yeah I instantly thought of it when I read this thread. Only one setback I can think of is it might not persist across reboots. Then again it's pretty easy to make a batch file to run the command so it won't need to be typed each time. Could even place a shortcut to it in the start menu's startup folder so it's automatically done at each login (if of course the command prompt flashing by on login isn't considered an annoyance).

  13. #13
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    Quote Originally Posted by jedaisoul View Post
    That takes me back. I did not know that old MSDOS command still works! If so, it is a far simpler solution.
    Not really because your links will end up with a directory structure referencing files:\\\X:\blah\blah\webpage.html where as installing XAMPP is as simple as a double click on an Icon, your testing will be exactly the same as it would be on a web host but all your debugging will be local.

    Really don't see how putting a development service on your PC is going to be a hard job.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  14. #14
    Join Date
    Jun 2004
    Location
    Tampa, Florida
    Posts
    77
    Well thanks everyone. I must say this webdeveloper forum is filled with some of the most helpful folks I've encountered in quite some time. Very refreshing. As is often the case, in the midst of many things to do I also have many new things to try. But that sure beats not having a clue with no one to help.

    As far as the web server, I guess I'm going to have to do this eventually, especially if I begin experimenting with a CMS system like Joomla. I do have my concerns though. First, I think it best i install a web server on another box. I certainly have extras floating around. That way I can better duplicate the operating environment of my hosting company. I am curious about the virtual drive solution too, and adding a name to my local hosts is an idea something I totally forgot! Lots of good tips. Thanks again everyone!
    Randy (PeterPan)
    * * *
    * *
    ... Second Star to the Right, and Straight on Till Morning!
    * * *

  15. #15
    Join Date
    Mar 2012
    Posts
    202
    Quote Originally Posted by \\.\ View Post
    Not really because your links will end up with a directory structure referencing files:\\\X:\blah\blah\webpage.html where as installing XAMPP is as simple as a double click on an Icon, your testing will be exactly the same as it would be on a web host but all your debugging will be local.

    Really don't see how putting a development service on your PC is going to be a hard job.
    I'd have to agree with you, and I would also recommend XAMPP as the software of choice. There is the right way of doing things, and the quick way of doing things. However sometimes the quick way doesn't hurt.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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