Forum Moderators: phranque

Message Too Old, No Replies

SSI used for files in different folders

how to keep the path?

         

mms19

1:08 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



I have some html files in the root folder using a SSI file, say header.inc, that contains some pictures by relative path, like /pic/abc.gif. Now I have some other html files in sub-folder, say /myfolder, that need to use the header.inc. If I include the header.inc in the files in /myfolder, the picture path will be wrong because there is no /myfolder/pic.

Instead of using the absolute path, how can I share the header.inc for files in different folders and keep the path right?

Thank you.

aus_dave

2:05 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



I might be missing something here, but if you prefix your links with '/' then they should all work fine.

e.g. /pics/pic.gif etc.

griz_fan

2:22 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



Yep... aus_dave is right. I've heard this type of pathing referred to as "root-relative" pathing. by beginning your link path with a forward-slash, you're basically specifying the web root as the starting point for the location of the file in the link. Traditional relative paths (i.e. ../dir/file.html) use the current file as the starting point.
So, in your case, as long as /pic is off the web root, you should be fine.

4serendipity

11:35 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



When making includes from the webserver root, be sure to use virtual includes instead of the more typical file includes.

Thus :
<!--#include virtual="/somedir/a.inc" -->
Will include a a file "a.inc" that is located at www.exmple.com/somedir/a.inc

In my experience trying to use
<!--#include file="/exp/a.inc" -->
will fail.

richardb

5:01 am on Sep 17, 2003 (gmt 0)

10+ Year Member



Hi 4serendipity

Depends on your server type

...apache use

<!--#include virtual=stuff -->

...M$

<!--#include file=stuff -->


Rich