Linux ~user with root-relative links

Discussion in 'NZ Computing' started by dave conz, May 6, 2004.

  1. dave conz

    dave conz Guest

    I have just set up a Red Hat 9 box to test websites and eventually be a
    file server for our LAN. That's all it will need to do.

    I have set up Apache to enable userdir so I can browse the sites by
    going to http://10.0.0.1/~user. It's going fine, but the problem is that
    I use a lot of root-relative links in my websites. Apache is looking for
    these links relative to the host IP address (10.0.0.1) rather than the
    user's document root (10.0.0.1/~user).

    Because I have numerous different users/websites on the go at any time,
    I really need to have a system that works without having to continually
    reconfigure document roots etc.

    Any suggestions for a way around this?

    -dave
    dave conz, May 6, 2004
    #1
    1. Advertising

  2. dave conz

    AD. Guest

    On Thu, 06 May 2004 12:46:22 +1200, dave conz wrote:

    > I have just set up a Red Hat 9 box to test websites and eventually be a
    > file server for our LAN. That's all it will need to do.
    >
    > I have set up Apache to enable userdir so I can browse the sites by going
    > to http://10.0.0.1/~user. It's going fine, but the problem is that I use a
    > lot of root-relative links in my websites. Apache is looking for these
    > links relative to the host IP address (10.0.0.1) rather than the user's
    > document root (10.0.0.1/~user).
    >
    > Because I have numerous different users/websites on the go at any time, I
    > really need to have a system that works without having to continually
    > reconfigure document roots etc.
    >
    > Any suggestions for a way around this?


    If you don't want to change all the links to the appropriate parent
    paths, you would probably have to set up a virtual host for each user in
    Apache.

    http://httpd.apache.org/docs/vhosts/index.html

    If you have lots of users and they change a lot, there are ways of
    automating it (I haven't tried this):

    http://httpd.apache.org/docs/vhosts/mass.html

    For our web designers, I set up a Debian server on our LAN with 10 virtual
    hosts on it eg webdev1, webdev2 etc put all the aliases in the DNS and
    also created a samba share to each host.

    Then they could edit SSI and php file to their hearts content, as well as
    copy whole sites in and out at once from their Windows desktops. 10 slots
    was enough for all the projects they had on at once.

    Cheers
    Anton
    AD., May 6, 2004
    #2
    1. Advertising

  3. dave conz

    steve Guest

    dave conz wrote:
    > I have just set up a Red Hat 9 box to test websites and eventually be a
    > file server for our LAN. That's all it will need to do.
    >
    > I have set up Apache to enable userdir so I can browse the sites by
    > going to http://10.0.0.1/~user. It's going fine, but the problem is that
    > I use a lot of root-relative links in my websites. Apache is looking for
    > these links relative to the host IP address (10.0.0.1) rather than the
    > user's document root (10.0.0.1/~user).
    >
    > Because I have numerous different users/websites on the go at any time,
    > I really need to have a system that works without having to continually
    > reconfigure document roots etc.
    >
    > Any suggestions for a way around this?
    >
    > -dave
    >


    How is your httpd.conf set up?

    I use "Virtualhost" in the httpd.conf - and each entry defines the
    'root' for that site.

    With Apache 2.0.49 (below /var) I use this option (along with others)

    DocumentRoot /www/<site-whatever>/html
    steve, May 6, 2004
    #3
  4. dave conz
    > I have just set up a Red Hat 9 box to test websites and eventually be a
    > file server for our LAN. That's all it will need to do.
    >
    > I have set up Apache to enable userdir so I can browse the sites by
    > going to http://10.0.0.1/~user. It's going fine, but the problem is that
    > I use a lot of root-relative links in my websites. Apache is looking for
    > these links relative to the host IP address (10.0.0.1) rather than the
    > user's document root (10.0.0.1/~user).
    >
    > Because I have numerous different users/websites on the go at any time,
    > I really need to have a system that works without having to continually
    > reconfigure document roots etc.
    >
    > Any suggestions for a way around this?


    No this is how Apache works, the web site root is not the site root and
    never will be, since the directories in question are subdirectories off
    the root.

    You might want to look at virtual hosting instead and I believe there are
    mechanisms for bulk configuration of this.
    Patrick Dunford, May 6, 2004
    #4
  5. dave conz

    pbs Guest

    dave conz wrote:
    > I have just set up a Red Hat 9 box to test websites and eventually be a
    > file server for our LAN. That's all it will need to do.
    >
    > I have set up Apache to enable userdir so I can browse the sites by
    > going to http://10.0.0.1/~user. It's going fine, but the problem is that
    > I use a lot of root-relative links in my websites. Apache is looking for


    Why use "root-relative" links?

    > these links relative to the host IP address (10.0.0.1) rather than the
    > user's document root (10.0.0.1/~user).


    Why not use links relative to the current URL (document)?
    eg <A HREF="subdir/index.html">subdir index</A>
    not <A HREF="http://10.0.0.1/subdir/index.html">subdir index</A>
    and not <A HREF="/subdir/index.html">subdir index</A>

    In the long run it makes it much easier to manage a site when the
    invertible move and reorganise of sets of web pages becomes necessary.
    Just the sort of thing you are describing here.
    pbs, May 7, 2004
    #5
  6. pbs
    > dave conz wrote:
    > > I have just set up a Red Hat 9 box to test websites and eventually be a
    > > file server for our LAN. That's all it will need to do.
    > >
    > > I have set up Apache to enable userdir so I can browse the sites by
    > > going to http://10.0.0.1/~user. It's going fine, but the problem is that
    > > I use a lot of root-relative links in my websites. Apache is looking for

    >
    > Why use "root-relative" links?
    >
    > > these links relative to the host IP address (10.0.0.1) rather than the
    > > user's document root (10.0.0.1/~user).

    >
    > Why not use links relative to the current URL (document)?
    > eg <A HREF="subdir/index.html">subdir index</A>
    > not <A HREF="http://10.0.0.1/subdir/index.html">subdir index</A>
    > and not <A HREF="/subdir/index.html">subdir index</A>
    >
    > In the long run it makes it much easier to manage a site when the
    > invertible move and reorganise of sets of web pages becomes necessary.
    > Just the sort of thing you are describing here.


    If your site uses a set of common images, includes etc, you'll want to
    use templates that have the absolute path to that image embedded in them
    so that it doesn't have to be changed every time you save the file in a
    different directory. I always use this on my websites using / as the
    root, not the full server name starting with http://
    Patrick Dunford, May 7, 2004
    #6
  7. dave conz

    Enkidu Guest

    On Sat, 8 May 2004 00:29:44 +1200, Patrick Dunford
    <> wrote:

    >pbs
    >> dave conz wrote:
    >> > I have just set up a Red Hat 9 box to test websites and eventually be a
    >> > file server for our LAN. That's all it will need to do.
    >> >
    >> > I have set up Apache to enable userdir so I can browse the sites by
    >> > going to http://10.0.0.1/~user. It's going fine, but the problem is that
    >> > I use a lot of root-relative links in my websites. Apache is looking for

    >>
    >> Why use "root-relative" links?
    >>
    >> > these links relative to the host IP address (10.0.0.1) rather than the
    >> > user's document root (10.0.0.1/~user).

    >>
    >> Why not use links relative to the current URL (document)?
    >> eg <A HREF="subdir/index.html">subdir index</A>
    >> not <A HREF="http://10.0.0.1/subdir/index.html">subdir index</A>
    >> and not <A HREF="/subdir/index.html">subdir index</A>
    >>
    >> In the long run it makes it much easier to manage a site when the
    >> invertible move and reorganise of sets of web pages becomes necessary.
    >> Just the sort of thing you are describing here.

    >
    >If your site uses a set of common images, includes etc, you'll want to
    >use templates that have the absolute path to that image embedded in them
    >so that it doesn't have to be changed every time you save the file in a
    >different directory. I always use this on my websites using / as the
    >root, not the full server name starting with http://


    Why not use virtual directories? I tend to have a single directory for
    common images like nav buttons. So the URL for an image might be
    /common-images/right-arrow.gif, with a physical address of
    /images/right-arrow.gif. For the site specific images I usually create
    another directory /images usually outside the site's physical address
    as a virtual directory for that site. That way you can use relative
    URLs everywhere and no absolute paths on the pages whatsoever.

    Cheers,

    Cliff
    Enkidu, May 8, 2004
    #7
  8. Enkidu
    > On Sat, 8 May 2004 00:29:44 +1200, Patrick Dunford
    > <> wrote:
    >
    > >pbs
    > >> dave conz wrote:
    > >> > I have just set up a Red Hat 9 box to test websites and eventually be a
    > >> > file server for our LAN. That's all it will need to do.
    > >> >
    > >> > I have set up Apache to enable userdir so I can browse the sites by
    > >> > going to http://10.0.0.1/~user. It's going fine, but the problem is that
    > >> > I use a lot of root-relative links in my websites. Apache is looking for
    > >>
    > >> Why use "root-relative" links?
    > >>
    > >> > these links relative to the host IP address (10.0.0.1) rather than the
    > >> > user's document root (10.0.0.1/~user).
    > >>
    > >> Why not use links relative to the current URL (document)?
    > >> eg <A HREF="subdir/index.html">subdir index</A>
    > >> not <A HREF="http://10.0.0.1/subdir/index.html">subdir index</A>
    > >> and not <A HREF="/subdir/index.html">subdir index</A>
    > >>
    > >> In the long run it makes it much easier to manage a site when the
    > >> invertible move and reorganise of sets of web pages becomes necessary.
    > >> Just the sort of thing you are describing here.

    > >
    > >If your site uses a set of common images, includes etc, you'll want to
    > >use templates that have the absolute path to that image embedded in them
    > >so that it doesn't have to be changed every time you save the file in a
    > >different directory. I always use this on my websites using / as the
    > >root, not the full server name starting with http://

    >
    > Why not use virtual directories? I tend to have a single directory for
    > common images like nav buttons. So the URL for an image might be
    > /common-images/right-arrow.gif, with a physical address of
    > /images/right-arrow.gif. For the site specific images I usually create
    > another directory /images usually outside the site's physical address
    > as a virtual directory for that site. That way you can use relative
    > URLs everywhere and no absolute paths on the pages whatsoever.


    And then what does your relative URL look like?
    Patrick Dunford, May 9, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ken
    Replies:
    0
    Views:
    411
  2. A.C.
    Replies:
    14
    Views:
    5,904
    Billh
    Nov 12, 2003
  3. Robert11
    Replies:
    0
    Views:
    675
    Robert11
    Dec 9, 2004
  4. Guest
    Replies:
    0
    Views:
    676
    Guest
    Mar 16, 2005
  5. Freezer

    Linux distro for a relative n00b?

    Freezer, Feb 23, 2007, in forum: Computer Support
    Replies:
    5
    Views:
    472
    Meat Plow
    Feb 23, 2007
Loading...

Share This Page