♦View your IP Address: (none)♦Members♦Help♦Bookmark♦NewHOT♦110mb♦Alexa Ranking♦
♦Study♦InfoTech♦Security♦Entertainment♦Tourism♦Career♦Social♦Business♦Science♦
♦California-USA: ♦
Include Command of SSI
Products / Services
The purpose of this quick guide is to show you how to include a file into another file using SSI. In order to include a file you must use the INCLUDE command!
The include command inserts the contents of a specified file into the response stream being sent to the client replacing the include directive. There are two kinds of includes:
Include File:
The file element is used with files which relative to the folder of the current document. In other words, the file which we want to include is in the same directory as the file which contains the include command or in a directory below the file. You can not use 'File' to go "up" a directory such as "../include-this.htm"
For instance:
<!--#include file="copyright.txt" -->
or
<!--#include file="includes/copyright.txt" -->
Include Virtual
The virtual element represents paths that are relative to the base folder of the Web server. In other words, virtual element should be used when the path to the document is given relative to the document root.
For instance:
<!--#include file="/copyright.txt" -->
or
<!--#include file="/includes/copyright.txt" -->
File Extensions of Included Files
The file to include can generally have any extension: .txt, .htm, .html, .inc, etc... If the document to be included contains SSI code which will need to be parsed by the server then it will have to have the extension .shtml or whatever your server is set-up to parse (process).
Unless you're executing a cgi script, you should always use "include". It's faster and safer.
Include other document via Ajax script
You can also use Ajax script below (DHTML interacting with the server) to let you include the contents of an external page onto the current document dynamically.
Step 1: Insert the below script to the HEAD section of your page:
<script type="text/javascript">
<!--
var rootdomain="http://"+window.location.hostname;
function ajaxinclude(url) {
var page_request = false;
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest();
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
else
return false;
page_request.open('GET', url, false); //get page synchronously
page_request.send(null);
writecontent(page_request);
}
function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText);
}
//-->
</script>
Note: Included file MUST be from the same domain as the page displaying it.
Step 2: Once that's done, to include an external page, simply use the below code in the BODY section of the master page where you want its contents to be shown:
<script type="text/javascript">
<!--
ajaxinclude("sample.html")
//-->
</script>
This will cause the script to retrieve "sample.html" and display its content on the page. You can call the above multiple times with different file names to include multiple files. Note that the included file MUST be from the same domain as the page including it due to security limitations with this feature.
You can also include the file by specifying the full URL to it on your server, such as:
<script type="text/javascript">
<!--
ajaxinclude(rootdomain+"/includes/sample.html")
//-->
</script>
"/includes/sample.html" is the path to your external file MINUS your domain name itself (ie: http://esiportal.110mb.com). Do not specify your domain, as the script will detect that by itself via the variable "rootdomain." Again, the limitation with both the included file and master page being on the same domain applies.
- Introduction to Server Side Includes (SSI).
- Enable SSI On Your Server via .htaccess file.
- Include Command of SSI.
- Echo Command of SSI.
- Date Command of SSI.
- Config Command of SSI.
- Exec Command of SSI.
- Other Basic Commands of SSI.
- SSI Conditional Basics.
- Conditional Expressions of SSI.
- Choose colors for your website.
- 10 Reasons Why People Don't Visit Your Web Site.
- 10 Profitable Reasons To Add A Discussion Board Or Chat Room To Your Web Site.
- 10 Legal Commandments for Your website.
- A sample for comments include Google Search results on Web, Videos, Blogs.
- Add Favicon to further promote your website.
- Website Design and content, technical guidelines and basic principles.
- List of common MIME types and their corresponding file extensions.
- What is a RSS Feed ? How to make Static Feeds and Dynamic Feeds.
- Resources design website for webmasters.
♦Email to your friend ♦Email to us ♦Get updates by Email ♦View updates on Web ♦Follow us on Twitter ♦Google Safe Browsing ♦McAfee SiteAdvisor ♦Diagnostic this page ♦Noreton SafeWeb ♦DrWeb ♦Technorati Links ♦Save to del.icio.us ♦Add to del.icio.us ♦Digg This! ♦Share on Facebook ♦outside.in: geotag this story ♦Discuss on Newsvine ♦Stumble It! ♦Add to Mixx!♦
If you would like to submit your website for FREE or advertise your own webpage(s) on our webpages, please enter Terms of Service webpage to send your request. Thank you!