Forum Moderators: phranque

Message Too Old, No Replies

SSI and htaccess

(for a single page only)

         

Reno

5:49 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want a single existing .html document to be able to include an SSI directive. There is a lot of info on the web about using .htaccess in parsing *all* pages in a directory, but as I said, I am only concerned about one single page, and I'm not having any luck finding that specific information. So my question is...

Is there a way to use .htaccess to allow a single page (foo.html) to include an SSI directive? If so, what is the code I would use in that .htaccess file?

Thanks for any advice...

jdMorgan

6:22 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, see the XBitHack directive in Apache mod_include. This allows you to mark one (or a few) files for SSI parsing by setting the "X bit" --the execute permission bit-- of the file.

Jim

encyclo

6:30 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also specify the files affected by a rule like this:

<Files foo.html>
AddHandler server-parsed .html
</Files>

Reno

6:35 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Jim. I had read that prior to my posting but being a non-server tech guy, I candidly did not understand what the process was to make it happen, and therefore was hoping that I could use htaccess.

Since adding my original post, another contact said to use:

<Files foo.html>
AddHandler server-parsed .html
</Files>

So if that sounds about right, then that will be the likely approach...

Reno

6:37 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Whoops -- thanks encyclo... I was adding my reply to Jim at the very moment you were adding your post. The info you included confirms that is the right path -- I appreciate the advice...

Reno

8:43 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Quick followup question...

If I had more than one file (let's say 3 pages out of 100), would I need to repeat your code 3 times in the htaccess, or, can I reference multiple files, as in:

<Files foo.html foo2.html foo3.html>
AddHandler server-parsed .html
</Files>

Each of those 3 is separated by a single space -- is that correct or should a comma be used?

Thanks for any feedback....

jdMorgan

2:51 am on Jan 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think you can do it with <Files>

Try <FilesMatch> instead:


<FilesMatch "^(File1¦File2¦File3)\.html$">
AddHandler server-parsed .html
</FilesMatch>\

Note that posting on this board modifies the pipe character; Change all broken pipe "¦" characters above to solid pipes before trying to use this code.

Jim

Reno

2:20 pm on Jan 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks again Jim. I looked through about a dozen online tutorials about htaccess and never found that specific info anywhere, so appreciate your advice as I'd hit a deadend...

Reno

4:53 pm on Jan 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Addendum...

I've been testing this today, and it worked beautifully however for my server I had to remove the ending "\" that you indicated, so it is:

<FilesMatch "^(File1¦File2¦File3)\.html$">
AddHandler server-parsed .html
</FilesMatch>

jdMorgan

5:09 pm on Jan 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, typo... :(

Jim