469,280 Members | 1,816 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,280 developers. It's quick & easy.

How to point to other URL's with #include command?

Hello all,

I've used the SSI Include command successfully in the past to include
frequently used files that are based within my own site. However, what
if I was to use a file located in a differnt location - a different
site altogether?

I've Googled different variations of "how to insert an URL using
#include" but all of the sites that came up never got beyond "file="
and "virtual=". There may be no more to it that that, but I'm not
sure.

I've tried <!--#include file="http://blahblahblah.com/filename.txt" -->
and other variations of that using CSS style "url('')" and "a href=",
but have gotten nowhere. Can this be done with the #include command? If
so, how?

The intended use is: I have someone who wants to add a schedule to a
website. The schedule will change frequently, causing a major hassle
for me. Ideally, I would have that person upload the file to their own
folder on the internet, and I would link to that file with the include
command, displaying the contents on the web page.

Thanks in advance.

Viken K.

Jan 31 '06 #1
5 3863
Viken Karaguesian wrote:
Hello all,

I've used the SSI Include command successfully in the past to include
frequently used files that are based within my own site. However, what
if I was to use a file located in a differnt location - a different
site altogether?

I've Googled different variations of "how to insert an URL using
#include" but all of the sites that came up never got beyond "file="
and "virtual=". There may be no more to it that that, but I'm not
sure.

I've tried <!--#include file="http://blahblahblah.com/filename.txt" -->
and other variations of that using CSS style "url('')" and "a href=",
but have gotten nowhere. Can this be done with the #include command? If
so, how?


No. The #include directive reads a file, it doesn't request a document
over the web. The server would also have to be a web client! So the
#include directive doesn't have that functionality.

If you're using ASP under IIS, you can use the WinHTTPServerRequest
ActiveX object to request the off-site page through code and write the
data returned out to the client. Other server-side technologies on other
web servers might provide a similar facility.
Jan 31 '06 #2
> No. The #include directive reads a file, it doesn't request a document
over the web. The server would also have to be a web client! So the
#include directive doesn't have that functionality.

Thanks Harlan. I've searched page after page in Google and hadn't found
any references to that, so I was coming to that conclusion on my own.

An better solution would be to provide her with a folder on the
webhost's server, give her a user name and password and have her copy
the file to that folder. Then I can link to the file from within the
site.

Don't know why I didn't think of that before...

Thanks for the reply.

Viken K.

Jan 31 '06 #3
On 31 Jan 2006 10:10:05 -0800, "Viken Karaguesian" <vi****@aol.com>
wrote:
I've used the SSI Include command successfully in the past to include
frequently used files that are based within my own site. However, what
if I was to use a file located in a differnt location - a different
site altogether?
It doesn't (stretching a point) have to be a file on the same _site_,
but it must be on the same filesystem that the web server uses.

Files, and especially include files, are quite a low-level part of the
web architecture and they're tightly coupled to how the server operates.
It should not have to read them every time the page is served, but it
must be able to tell when they've been changed (so it can include the
new version). Generally a good server will do the merging once, then
cache the merged copy until something changes.

So if you separate the web server from its include files, then you're
making life very difficult for the server. This is why you can only
process includes from a "file" attribute or a "virtual" attribute which
maps onto a local file, but there's no "web address" or "href"
attribute.

There are several options for you.

* <iframe>
This is the closest to "include files over the web", but it's done on
the client (web browser) side. It has drawbacks. You'll also need the
content author to have their own full-powered web hosting.

* Upload to your server.
Have the author make the file on their desktop machine, then upload it
(by ftp, or more sophisticated means) to your web server. Good hosting
packages allow you to create restricted ftp accounts that only access
subdirectories, which are ideal for this. This is probably the best
solution.

* Weblog
Install some simple weblogging software on your server, configure it to
turn nearly all features off, then let the content author be the one
user who can make postings to it. This is a good solution if the
content author is not technically expert - remember that an error in
their content might break a lot of your site!

Ideally, I would have that person upload the file to their own
folder on the internet, and I would link to that file with the include
command, displaying the contents on the web page.


What's a "folder on the internet" ? Do they have web hosting of their
own, and does it have adequate capacity for this purpose ? If they can
upload to "their folder", then they can probably upload to a directory
on your server just as easily.
Jan 31 '06 #4
> * Upload to your server.
Have the author make the file on their desktop machine, then upload it
(by ftp, or more sophisticated means) to your web server. Good hosting
packages allow you to create restricted ftp accounts that only access
subdirectories, which are ideal for this. This is probably the best
solution.
This is exactly what I plan to do. I don't know why I didn't think of
it before. See my reply to Harlan.
What's a "folder on the internet" ? Do they have web hosting of their
own, and does it have adequate capacity for this purpose ?


Many ISP's, like mine (Comcast) offer "personal web spaces" with their
accounts. This is a folder that you can put a website in or just put
files for you and others to access. She has Comcast, so she as a folder
to which she can upload. But the previously mentioned solution is
better.

Thanks.

Viken K.

Jan 31 '06 #5
Viken Karaguesian wrote:
Hello all,

I've used the SSI Include command successfully in the past to include
frequently used files that are based within my own site. However, what
if I was to use a file located in a differnt location - a different
site altogether?

I've Googled different variations of "how to insert an URL using
#include" but all of the sites that came up never got beyond "file="
and "virtual=". There may be no more to it that that, but I'm not
sure.


There are ways to do that. In Apache, mod_publisher gives you
<!--#include url="..."-->. Or an ESI processor will do an
essentially-equivalent job.

Whatever you use, make sure you have some sensible cacheing
regime on your server, so you're not fetching something by HTTP
on every hit.

--
Nick Kew
Feb 1 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Roger Leigh | last post: by
5 posts views Thread by Anton Noll | last post: by
5 posts views Thread by juergen perlinger | last post: by
1 post views Thread by John | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.