Make Apache process .html files for SSI includes

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

Make Apache process .html files for SSI includes

Postby Dale Ray » Tue Jun 22, 2004 8:32 pm

The current release version (1.23) of Coranto does not allow you to specify the extension of the static file created by a standard profile using a template file (.tmpl file). Most Apache servers are set up to require the .shtml extension on files you want to be processes for server side includes (SSI).

You can get around this limitation with a directive in the .htaccess file in your news directory.

Place this line:

Code: Select all
AddHandler server-parsed .html


in the .htaccess file. If there is already an .htaccess file in the directory add the line. If the file does not exist, create the file with any text editor and upload it to the directory.

This will cause the server to process all files ending with the standard .html extension for includes.

Make this change only to the .htaccess file only in the directories you absolutely need it in. It effects files in the directory the file is in and all sub-directories. If you were to place this in your web root ALL .html files on your site would be processed increasing the server load.

Using this technique you can put includes in the template for your profile and the server will process them when the file is requested by a client. Adding headlines, headers, or footers can be done using this technique.

Why bother to create a static page and then use includes? For the same reason you use includes to begin with. If you have a site header, footer, or navigation bar and use SSI to include on every page in your site you can use this to extend the use of those files to your Coranto generated pages. If the Coranto news represents the largest amount of text on the page it will still cut some load off the server. Also some search engines and site search tools deal better with static pages.

Not all hosts allow you to do this. If the server is set up to not allow over rides to the default configuration you may not be able to use this method. This applies to Apache servers only.
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby Dale Ray » Mon Jul 12, 2004 3:40 am

While researching another aspect of Apache server settings I cam across this from the apache docs:
Code: Select all
Not just any file is parsed for SSI directives. You have to tell Apache which files should be parsed. There are two ways to do this. You can tell Apache to parse any file with a particular file extension, such as .shtml, with the following directives:

        AddType text/html .shtml
        AddHandler server-parsed .shtml

One disadvantage to this approach is that if you wanted to add SSI directives to an existing page, you would have to change the name of that page, and all links to that page, in order to give it a .shtml extension, so that those directives would be executed.

The other method is to use the XBitHack directive:

        XBitHack on

XBitHack tells Apache to parse files for SSI directives if they have the execute bit set. So, to add SSI directives to an existing page, rather than having to change the file name, you would just need to make the file executable using chmod.

        chmod +x pagename.html

A brief comment about what not to do. You'll occasionally see people recommending that you just tell Apache to parse all .html files for SSI, so that you don't have to mess with .shtml file names. These folks have perhaps not heard about XBitHack. The thing to keep in mind is that, by doing this, you're requiring that Apache read through every single file that it sends out to clients, even if they don't contain any SSI directives. This can slow things down quite a bit, and is not a good idea.

Of course, on Windows, there is no such thing as an execute bit to set, so that limits your options a little.


Using the Xbit hack is obviously the preferred method to tell the server to process files without the shtml extension for SSI and it also will work for any file extension.

Testing this may be the only way to tell if your host allows this.
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana


Return to Customization

Who is online

Users browsing this forum: No registered users and 0 guests

cron