Path for SSI in htm file

P

Poten Tate

I'm on an apache server and am using the xbithack directive in my .htaccess
file. Here's how I use an include file (SSI) in my htm file--

<!--#include file="./thefile.txt" -->

It works perfectly.

The ./ means "thefile.txt" is in the same directory as the htm file that
contains the SSI. Here's where the htm file is--

public_html/folder1/folder2/htm_file.htm

For the life of me I can't figure how to go back 2 folders to--

public_html/folder0/anotherfile.txt

I've tried--

<!--#include file="/../../folder0/anotherfile.txt" --> and--

<!--#include file="../../folder0/anotherfile.txt"-->

and lots of other paths but can't get it to work. Does anyone know the
correct syntax? Thanks.
 
M

mbstevens

I've tried--

<!--#include file="/../../folder0/anotherfile.txt" --> and--

<!--#include file="../../folder0/anotherfile.txt"-->

and lots of other paths but can't get it to work. Does anyone know the
correct syntax? Thanks.

I suspect that you don't want to use 'folder0/'
Instead, try:
<!--#include file="../../anotherfile.txt" -->
....*if* anotherfile.txt is in a folder two directories up named folder0.
But it's hard to say without actually being able to look at a printout
of the directories in question.
 
P

Poten Tate

I suspect that you don't want to use 'folder0/'
Instead, try:
<!--#include file="../../anotherfile.txt" -->
...*if* anotherfile.txt is in a folder two directories up named folder0.
But it's hard to say without actually being able to look at a printout
of the directories in question.


mb, the name "folder0" is just an example, not the actual folder name. The
actual folder name is "ads." The code you suggested above, and which I've
already tried, gives me an "[an error occurred while processing this
directive]" error. Below are the actual names of the folders. Thanks for
your help.

public_html/seasonal/code/ssis.htm - where I am

public_html/ads/burst728x90.txt - where I'm trying to go from above.
 
J

Jonathan N. Little

Poten said:
I'm on an apache server and am using the xbithack directive in my .htaccess
file. Here's how I use an include file (SSI) in my htm file--

<!--#include file="./thefile.txt" -->

It works perfectly.

The ./ means "thefile.txt" is in the same directory as the htm file that
contains the SSI. Here's where the htm file is--

public_html/folder1/folder2/htm_file.htm

For the life of me I can't figure how to go back 2 folders to--

public_html/folder0/anotherfile.txt

I've tried--

<!--#include file="/../../folder0/anotherfile.txt" --> and--

Well, a leading "/" above the root which will not be correct, what you
want is up 3 to "public_html" then down one "folder0"
<!--#include file="../../folder0/anotherfile.txt"-->

and lots of other paths but can't get it to work. Does anyone know the
correct syntax? Thanks.

<!--#include file="../../../folder0/anotherfile.txt" -->
 
P

Poten Tate

Well, a leading "/" above the root which will not be correct, what you
want is up 3 to "public_html" then down one "folder0"

Is this what you're suggesting (see below) and actual names of the folders.

<!--#include file="../../../ads/burst728x90.txt" -->

It doesn't work. If I've coded it wrong please give me an example. As
mentioned earlier I've tried every variation of the path that I can think
of. I've looked this up on the Internet and others can't get it work either.
Or I've not seen a definitive answer. Thanks.
 
J

Jonathan N. Little

Poten said:
Is this what you're suggesting (see below) and actual names of the folders.

<!--#include file="../../../ads/burst728x90.txt" -->

It doesn't work. If I've coded it wrong please give me an example. As
mentioned earlier I've tried every variation of the path that I can think
of. I've looked this up on the Internet and others can't get it work either.
Or I've not seen a definitive answer. Thanks.
I think we need the complete paths to both files.
 
P

Poten Tate

Jonathan, maybe this will explain it better. I posted this on another forum.
Thanks.

This works perfectly on my Red Hat Linux server. I'm using the 'xbithack' in
my .htaccess file.

<!--#include file="thefile.txt" --> -- the SSI

Here's my location according to ws_ftp

public_html/folder1/folder2/my_htm_file.htm (this contains the SSI above)

I have a folder containing all my text files and it's located at--

public_html/text_files_folder

From within the htm file and the location above -
public_html/folder1/folder2/my_htm_file.htm - I want to include an SSI that
gets the file from - public_html/text_files_folder

I've tried these combinations (see below) and lots of others but nothing
will get the file. I keep getting an "[an error occurred while processing
this directive]" error.

<!--#include file="/public_html/text_files_folder/show_this_file.txt" -->

<!--#include file="/text_files_folder/show_this_file.txt" -->

<!--#include file="../text_files_folder/show_this_file.txt" -->

<!--#include
file="../../public_html/text_files_folder/show_this_file.txt" -->

<!--#include file="../../../text_files_folder/show_this_file.txt" -->

<!--#include
file="http://www.mywebsite/text_files_folder/show_this_file.txt" -->

Nothing works. Does anyone know how to do this? It seems to be a problem
with others as well. I've done a search on the Internet and have seen no
definitive answer. Does anyone know the correct syntax? Thanks.

As mentioned earlier, if I include the "show_this_file.txt" in the same
folder as"my_htm_file.htm" this code works perfectly.

<!--#include file="thefile.txt" -->

Anyone?????
 
P

Poten Tate

<!--#include file="thefile.txt" -->

(see above) At the very end of the previous post this should have been
<!--#include file="show_this_file.txt" -->

I'm wondering if you go back up from a directory with an SSI. You can go
forward in a directory because I can do that.
 
P

Poten Tate

This href link works perfectly. But the SSI doesn't. Crazy!

<!--#include file="../../ads/burst728x90.txt" -->

<a href="../../ads/burst728x90.txt">go here</a>
 
J

Jonathan N. Little

Poten said:
Jonathan, maybe this will explain it better. I posted this on another forum.
Thanks.

This works perfectly on my Red Hat Linux server. I'm using the 'xbithack' in
my .htaccess file.

<!--#include file="thefile.txt" --> -- the SSI

Here's my location according to ws_ftp

public_html/folder1/folder2/my_htm_file.htm (this contains the SSI above)

I have a folder containing all my text files and it's located at--

public_html/text_files_folder

From within the htm file and the location above -
public_html/folder1/folder2/my_htm_file.htm - I want to include an SSI that
gets the file from - public_html/text_files_folder

I've tried these combinations (see below) and lots of others but nothing
will get the file. I keep getting an "[an error occurred while processing
this directive]" error.

<!--#include file="/public_html/text_files_folder/show_this_file.txt" -->

<!--#include file="/text_files_folder/show_this_file.txt" -->

<!--#include file="../text_files_folder/show_this_file.txt" -->

<!--#include
file="../../public_html/text_files_folder/show_this_file.txt" -->

<!--#include file="../../../text_files_folder/show_this_file.txt" -->

from what you show this path should be correct, but the path may not be
your problem but your server may not allow direct includes for security
reasons and may require the "virtual" keyword. Mine does.

<!--#include virtual="../../../text_files_folder/show_this_file.txt" -->
 
M

mbstevens

I suspect that you don't want to use 'folder0/'
Instead, try:
<!--#include file="../../anotherfile.txt" -->
...*if* anotherfile.txt is in a folder two directories up named folder0.
But it's hard to say without actually being able to look at a printout
of the directories in question.


mb, the name "folder0" is just an example, not the actual folder name. The
actual folder name is "ads." The code you suggested above, and which I've
already tried, gives me an "[an error occurred while processing this
directive]" error. Below are the actual names of the folders. Thanks for
your help.

public_html/seasonal/code/ssis.htm - where I am

public_html/ads/burst728x90.txt - where I'm trying to go from above.

Oh. Then you would want...

.../../ads/burst728x90.txt

In painful detail:

'ssis.htm' is in the 'code' directory.

the first '../' takes you up to the 'seasonal' directory

the second '../' takes you up to the 'public_html' directory.
This directory has the 'seasonal' directory you just came from,
but also the 'ads' directory you are going to.

From that directory you go down into the 'ads' directory with 'ads/'
before calling the text file.
 
P

Poten Tate

Thanks for the replies, guys but nothing has worked. So I am using an iframe
and it works OK (see below). The paths for SSI are a little different. I
have no idea how they work.

<iframe name="I1" src="../../ads/burst728x90.htm" width="763" height="125"
border="0" frameborder="0">
</iframe>
 
J

Jonathan N. Little

Poten said:
Thanks for the replies, guys but nothing has worked. So I am using an iframe
and it works OK (see below). The paths for SSI are a little different. I
have no idea how they work.

<iframe name="I1" src="../../ads/burst728x90.htm" width="763" height="125"
border="0" frameborder="0">
</iframe>
As I said, maybe your server does not allow a direct included for
security reasons and you must use "virtual"

change from:

<!--#include file="...

to:

<!--#include virtual="...

Also try including a file in the same folder to insure that you do have
SSI available...
 
P

Poten Tate

As I said, maybe your server does not allow a direct included for security
reasons and you must use "virtual"

change from:

<!--#include file="...

to:

<!--#include virtual="...

Also try including a file in the same folder to insure that you do have
SSI available...


Jonathan, excuse the email to your personal email address. I hit 'reply'
instead of 'reply group.'

I have no problem when both files are in same directory as stated
in my first post. But, the <!--#include virtual="... doesn't work either.
I'm going to use iFrame. Thanks.
 
J

Joe (GKF)

I'm on an apache server and am using the xbithack directive in my .htaccess
file. Here's how I use an include file (SSI) in my htm file--

<!--#include file="./thefile.txt" -->

It works perfectly.

The ./ means "thefile.txt" is in the same directory as the htm file that
contains the SSI. Here's where the htm file is--

public_html/folder1/folder2/htm_file.htm

For the life of me I can't figure how to go back 2 folders to--

public_html/folder0/anotherfile.txt

I've tried--

<!--#include file="/../../folder0/anotherfile.txt" --> and--

<!--#include file="../../folder0/anotherfile.txt"-->

and lots of other paths but can't get it to work. Does anyone know the
correct syntax? Thanks.

<!--#include virtual="/folder0/anotherfile.txt" -->
The virtual argument is used to begin the search for files from the ROOT
level.
 
J

Jonathan N. Little

Joe (GKF) wrote:
<!--#include virtual="/folder0/anotherfile.txt" -->
The virtual argument is used to begin the search for files from the ROOT
level.

Not sure what you mean there. Using a leading "/" will put it into the
Document Root, not the absolute root, whatever is set be the webserver.

If "public_html" is the Document Root then

<!--#include virtual="/some.file" -->


will mean "some.file" is in the "public_html" folder. On the file system
"public_html" may be "/var/www/clientsites/example.com/public_html"

If OP's "public_html" is his Document Root, rather than fussing with the
relative path just go absolute from Document Root and be done with it,
then it won't matter where the calling SHTML doc is.

<!--#include virtual="/text_files_folder/show_this_file.txt" -->
 
J

Jonathan N. Little

Joe said:
I'm confused now, Jonathan. How is what I said different from what you
said?

As I said "Not sure what you mean there. Using a leading "/" will put it
into the Document Root, not the absolute root, whatever is set be the
webserver."

But if you have a but if you do not have a leading "/" SSI will work
with a relative path, your remarks appears to imply that the "virtual"
argument does not support relative paths which is not true.
 
J

Joe (GKF)

As I said "Not sure what you mean there. Using a leading "/" will put it
into the Document Root, not the absolute root, whatever is set be the
webserver."

But if you have a but if you do not have a leading "/" SSI will work
with a relative path, your remarks appears to imply that the "virtual"
argument does not support relative paths which is not true.
gotcha. I say, gotcha.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top