开发者

How to include a file from an HTTP address outside my server?

I ju开发者_StackOverflowst read a little tutorial on SSI and managed to show what I wantedbut I'd like to use an http path to point at this file so I can use it with sites in differente servers. How can I do it?

The path of the file I want to show is "http://chusmix.com/menubar/bar.html"

Thanks!


If you really want to, you can write up a CGI script that simply calls wget or curl, on the desired url and include it via a virtual include call.

<!--#include virtual="/cgi-bin/url_getter.cgi?url=YOUR_URL" --> 

That's the safest bet. If you want to do something a little less secure, you can do it via a direct call to wget or curl via an exec include call.

<!--#exec cmd="wget YOUR_URL" --> 

Most hosting providers disable the exec call by default because it really isn't a good idea to use it. Don't use it, use a virtual call instead.

But to be honest, just including external pages like that is pretty unsafe, unless you happen to also control the page on the other server. Don't forget that the other page could contain javascript and hence do undesirable things to visitors of your page, who implicitly trust you, but maybe not the external source.


You cannot reference a URL with the #include SSI directive in either IIS or Apache.

The only way to "include" remote content is to use Javascript (possibly with Ajax) or a server-side HTTP request.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜