Novice question regarding root level URLs

topic posted Mon, December 6, 2004 - 12:03 PM by  Pink
I am running Apache on Mac OS X.

I have this question that I might not be phrasing correctly but maybe someone here can help with an answer.

here is what i want to do -

i want to be able to use the back slash in a URL reference like so:

<img src="/globalimages/spacer.gif">

i want to be able to use this within a Users website, ie if i have a User on the machine and their login is wilbur, so that the URL to their website would be:

http://127.0.0.1/~wilbur

i want the URL :

src="/globalimages/spacer.gif"

to go to:

src="http://127.0.0.1/~wilbur/globalimages/spacer.gif"

AND NOT to src="http://127.0.0.1/globalimages/spacer.gif"

which is what it currenlty does.

I have combed the internet and APache places for this info and have been unsuccessful probably because i don't know how to phrase the question technically. I hope that it is something that I can tweak in the server config. file which I know how to edit and change.

The reason why I want to do this is because I develop websites for various clients and I give each client a User account and then develop the site there. The only problem is that the User account isn't at the root level of the server and therefore I can't use URLs that begin with "/" in order to refer to a global image or file like an include.

It just bugs me that I can't do it and bugs me more that I can't figure it out. Maybe if I read 500 Pages of a Apache manual I would finally find it.

I am really just looking for the answer than I am looking for references that might have the answer that I have to weed through.

Thanks

pink
posted by:
Pink
Los Angeles
  • Re: Novice question regarding root level URLs

    Mon, December 6, 2004 - 6:05 PM
    Why use absolute URLs instead of relative ones? I thought relative URLS using .. if necessary were the standard technique.
    • Re: Novice question regarding root level URLs

      Tue, December 7, 2004 - 6:08 AM
      I _know_ I repsponded to this yesterday, but the message has vanished!

      I can't help with specifics, especially since I am not familiar with the MAC setup, but you want to do some research on setting up "Virtual hosts". In addition to adding the info to the Apache's httpd.conf file, on Windows you need to add the virtual-host to the, er, HOSTS file.

      On the MAC, well... I dunno.

      I beat my head against this one for a week or so, until somebody pointed me in the right direction, and then I beat my head against the specifics for another week...

      ----

      absolute vs. relative : f'r instance, I use PHP to include some fragments that refer to other files; since the fragments can be called from any level of my site sturcture, their inclusions can not be relative, but must be absolutely directed against the root (wherever that may happen to be). with a virtual host on my local machine and absolute paths in my website, my local-mirror and live versions function identically.

      for the most part.
      • Re: Novice question regarding root level URLs

        Tue, December 7, 2004 - 5:39 PM
        If I were in the original poster's situation, I would probably want to use virtual hosts instead of userdirs, since I found how to do virtual hosting with no additional Apache setup per domain: (advice reposted from an earlier topic)

        Using VirtualDocumentRoot, VirtualScriptAlias, and directories whose names are the domains served, is far easier than listing each domain in httpd.conf, as well as the only way I've found to host multiple domains on the same dynamic IP. I missed this technique through a couple of reads of the manual because it takes so little space to describe and most of the section is devoted to explaining the older methods of manually configuring each site.

Recent topics in "Apache Web servers"

Topic Author Replies Last Post
New mac dev help needed jedi 1 August 11, 2007
can you be on call for this server and make some easy cash? 0 June 13, 2007
hosting reliability and live support 4 February 10, 2007
mySQL nat 2 November 29, 2006