Update Identicle Part of Multiple Sites From 1 File?

I’m going to be displaying some information + links on multipe different sites and ill be changing the information/links sometimes… Instead of having to update every single site is there a way I can have all the websites get the information from 1 single file? so when the file is changes it changes the information on all the websites at once?

Please research server side includes. The Apache web server, among others, supports pre-processing instructions. See the Apache manual.

Alternatively, use the include function that most, if not all, server languages support. See your language manual.

cheers,

gary

would the sites have to be on the same server since u suggested server side includes?

which server side programming language you are using to create website.

vineet

If you use something like PHP includes, yes you can insert the file from your different servers/sites and they should update automatically assuming your servers are correctly set-up and allow it, etc.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

This is a rough example of PHP server side includes. Say that above code will be EVERYWHERE in the site. Let’s call that header.php
On your other page…lets call it blog.php, just add this at the top of the file, and it will sorta like cut and paste the header.php content directly into blog.php (not really, but it’s similar)


<!--blog.php-->
<?php include("header.php"); ?>
<!--rest of page blah blah-->

One way to include an HTML fragment is with “server-side includes”. However, this only works within one server - ie, you would need a separate setup on each server you are using.

To do this, you need to rename all your files to .shtml instead of .htm or .html - you can then use the code <!--#include virtual="/file.htm" -->, where “file.htm” is the fragment to be included in each page. You can either set a root reference, as here, or a relative reference, eg “…/dynamic/file.htm”.

Server configuration ios a separate issue. The include syntax is standardized since the first server, NCSA HTTPd.

To do this, you need to rename all your files to .shtml instead of .htm or .html - you can then use the code <!--#include virtual="/file.htm" -->, where “file.htm” is the fragment to be included in each page. You can either set a root reference, as here, or a relative reference, eg “…/dynamic/file.htm”.
Not necessarily; In Apache, at least, you can set the xBitHack on. If you do, you may keep the “normal” extensions, and simply set the x bit on the file using chmod +x <filename>.

cheers,

gary

Sorry, what I meant was that on pages on website1.com could include “website1.com/fragment.htm”, but if you needed to include the same code on pages on website2.com, you would need to set up “website2.com/fragment.htm” - you can’t include fragments from another server.

Hmmm, that last seven words summed it up perfectly. Why did I make such a hash of explaining it earlier?

Not necessarily; In Apache, at least, you can set the xBitHack on. If you do, you may keep the “normal” extensions, and simply set the x bit on the file using chmod +x <filename>.

Well you learn something new every day! If I’d known that 3 years ago, I wouldn’t have had to mess around with mod_rewrite to map all my .htm files into .shtml ones…

For the details of SSI, and using the XBitHck, see http://httpd.apache.org/docs/2.2/howto/ssi.html.

cheers,

gary