homepage Welcome to WebmasterWorld Guest from 54.243.23.129
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
Forum Library, Charter, Moderators: phranque

Website Technology Issues Forum

    
How can I link to one SSI file from pages in separate directories?
SSI files stop working when I put pages in different directories
bouncybunny




msg:3841818
 6:13 am on Feb 4, 2009 (gmt 0)

I have a couple of SSI files in the root directory of my web site which I use for navigation bars. Everything works fine for the home page, but when I duplicate the page into a subdirectory and update the file path in the code, the SSI doesn't load.

This happens locally and also on the server.

For example for the home page the link to the SSI file is

navgation-left.ssi

and when I put the page into a subdirectory the link might be

../navgation-left.ssi

This all looks fine to me, but clearly I am missing something.

 

g1smd




msg:3841972
 11:32 am on Feb 4, 2009 (gmt 0)

Omit the double dots.

Double dots means "up one level".

Keeping track of that down multiple levels is a nightmare.

Use /nav-left.ssi with a leading slash so that you always "count from the root".

coopster




msg:3842126
 2:29 pm on Feb 4, 2009 (gmt 0)

I agree, navigating from the root keeps things so much cleaner and easier to use, less confusing when you are trying to determine where your current filepath is too. If you are on Apache use virtual, not file -- virtual [httpd.apache.org] is much more useful.

g1smd




msg:3842623
 12:50 am on Feb 5, 2009 (gmt 0)

With "counting from the root" the current location becomes irrelevant.
That's why I find it so useful.

bouncybunny




msg:3842744
 5:43 am on Feb 5, 2009 (gmt 0)

Sorry, but none of those solutions work. Perhaps I didn't explain this properly. I want to bring in the ssi file that is up one level.

I am only putting the html page down one level of directory. Surely the double dots points the link back at the root directory where the SSI file is?

I am not on Apache (Windows IIS), so the virtual option doesn't seem to work either.

So, if the html page and the ssi file are in the same root directory I have been using <!--#include file="nameofile.ssi" -->

Then I put another page one directory level down, but keep the ssi file in the root directory, shouldn't it become <!--#include file="../nameofile.ssi" -->

bouncybunny




msg:3843471
 3:33 am on Feb 6, 2009 (gmt 0)

Ah, ok. I realised that it was the images in the ssi file that were not showing up. I suppose I will have to use absolute links for them.

g1smd




msg:3843594
 9:12 am on Feb 6, 2009 (gmt 0)

Yes. Use the same "starts with slash" URL format for all links to CSS, JS, images, etc.

rocknbil




msg:3843860
 4:18 pm on Feb 6, 2009 (gmt 0)

I have been using <!--#include file="nameofile.ssi" -->

See coopster's previous post - the "rule of thumb" with SSI is if it's in the same directory, use file, if it's in a different directory, use virtual..

<!--#include virtual="/nameofile.ssi" -->
<!--#include virtual="/dir/nameofile.ssi" -->

The "dot syntax" will always get you in trouble, or at least confused. Do the same within your SSI files:

/images/some-image.jpg

Never

../../some-image.jpg

(An ailment similar to Larry Wall's "toothpick syndrome")

Then I put another page one directory level down, but keep the ssi file in the root directory, shouldn't it become <!--#include file="../nameofile.ssi" -->

It could, but if you use the previous advice and do

/nameofile.ssi

you can move it anywhere.

Adapting this habit will allow you to move your files anywhere on your system and they will always connect, you won't even have to look. :-)

bouncybunny




msg:3844187
 11:49 pm on Feb 6, 2009 (gmt 0)

Thanks. But will that method work on a windows IIS server? I thought I require Apache?

bouncybunny




msg:3844323
 8:26 am on Feb 7, 2009 (gmt 0)

Ah. Thank you thank you everyone. It all falls into place at last. Just need to test everything on the server and I'm good to go.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved