Server-Side Includes with .html files (XPSP3) 1.7.7 [SOLVED]

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Server-Side Includes with .html files (XPSP3) 1.7.7 [SOLVED]

Postby hydrurga » 05. December 2011 19:49

Hi there,

I hope that this isn't too naive a question. I'm running XAMPP with various virtual hosts. One of these hosts has an index.shtml and the rest of its files as .html (but still consisting of SSI includes). XAMPP status shows that SSI is running correctly.

I added the line
Options Indexes FollowSymLinks Includes

to the relevant <directory> entry in the corresponding <VirtualHost *> entry in httpd-vhosts.conf. Index.shtml works perfectly but none of the others (all .html files) parse correctly. Essentially what I need to do is tell Apache that all .html files in that directory should be parsed as if they were .shtml files.

I've tried separately placing
AddHandler server-parsed .html .htm

and
Addhandler application/x-httpd-parse .html .htm

after the aforementioned Options line but with no success. Is there something I'm missing?
hydrurga
 

Re: Server-Side Includes with .html files

Postby Sharley » 05. December 2011 22:54

Where is the <Directory> or folder located (path) of the vhost with the SSI files?

Is it in the htdocs folder (the server DocumentRoot) or outside the htdocs folder?

The working index.shtml is a server wide configuration setting found in the httpd.conf file.

The settings in the vhost will override the httpd.conf file settings.

This may be required
Code: Select all
Options Indexes FollowSymLinks +Includes
AllowOverride All


You could try this
Code: Select all
AddHandler server-parsed .shtml .html .htm
AddType text/html .shtml .html .htm
AddOutputFilter INCLUDES .shtml .html .htm
Remember to save the httpd-vhost.conf file and then restart Apache after each edit, for testing.


Often to save confusion it is best to have all your html coded file extensions as .html not a mix of .html and .htm - just a preferred method I use where possible.
( I believe M$ introduced this confusion by using .htm extensions instead of what was an industry standard at the time .html extension and again I believe because of the old 8.3 file naming convention in DOS and earlier Windows ).

So if you can use just .html adjust the above code to suit.


Having all files parsed by the server can add extra load on the server especially if the server is a busy server and so introduce delays (lag) - you should consider this fact when developing.

This link may hold an interesting alternative to having all html files that do not contain SSI parsed by the server:
https://my.bluehost.com/cgi/help/257


If you encounter more problems then would you mind pasting your actual vhost container that you want SSI settings from your httpd-vhosts.conf file please so I can take a look at how your vhosts is constructed and provide a possible solution - you can obfuscate any sensitive info if you wish.

Good luck. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Server-Side Includes with .html files

Postby hydrurga » 07. December 2011 14:33

Hi Sharley,

Many thanks for getting back to me. The only modifications I have made have been to httpd-vhosts.conf, I have not touched httpd.conf. Following your suggested modifications (after which Apache was restarted), the entry in httpd-vhosts.conf reads (the actual domain name has been changed in all cases to XXX):

Code: Select all
<VirtualHost *>
  DocumentRoot "C:\Web Sites\XXX\www"
  ServerName xxx.test
  <Directory "C:\Web Sites\XXX\www">
    Options Indexes FollowSymLinks +Includes
    AllowOverride All
    AddHandler server-parsed .shtml .html .htm
    AddType text/html .shtml .html .htm
    AddOutputFilter INCLUDES .shtml .html .htm
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>


The current situation is that a file with a .shtml extension will be parsed correctly, but exactly the same file with the extension changed to .html will not be parsed correctly.

Thanks again, and let me know if there is any more info that you need!

Cheers.
hydrurga
 

Re: Server-Side Includes with .html files

Postby hydrurga » 07. December 2011 14:59

Hi Sharley,

Just a quick note. If I load up index.shtml and then click through the links on that page to the .html pages then they are parsed correctly. However if I load up one of the .html pages directly through the address bar then it isn't parsed correctly. Obviously a solution would be for me to rename all the .html files to .shtml, but I am still wondering why I cannot force Apache to parse the .html files. In an ideal world I would obviously go ahead and implement the site in php but it is not advantageous for me to do so in this case for various reasons.

Cheers.
hydrurga
 

Re: Server-Side Includes with .html files

Postby Sharley » 07. December 2011 15:18

There are a few things in your vhost that may need some attention as Apache and MySQL really don't like spaces in file or folder names.
Try and rename the Web Sites folder to lower case and remove the space - Apache is case sensitive so any slip ups will cause an error not to mention confusion for you, try and keep all things lower case.

Here is an amended container, that I have assumed you did not provide the full set and you should always have the default first container set to localhost
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName xxx.test
DocumentRoot "C:/websites/XXX/www"
<Directory "C:/websites/XXX/www">
Options Indexes FollowSymLinks +Includes
AllowOverride All
AddHandler server-parsed .html .htm .shtml
AddType text/html .html .htm .shtml
AddOutputFilter INCLUDES .html .htm .shtml
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I have just changed the extension order to see if that helps but if not then create a separate line for each extension for example:
AddHandler server-parsed .html
AddHandler server-parsed .htm
AddHandler server-parsed .shtml
etc.

You have added xxx.test to the Windows HOSTS file?

To see if there any issues with the vhost configuration file then in the xampp-control-3-beta.exe control panel found in the xampp folder click on the XAMPP-Shell button and type httpd.exe -S and if you don't understand the results then in the top right of the console window is a small icon that holds the Edit functions that you can use to mark and copy them to this topic.

There should be no reason that I can see for the SSI settings I posted not working except perhaps the order of the file extensions and to eliminate that possibility create that separate line for each file extension for all directives after testing the single lines with the changed order.

Good luck. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Server-Side Includes with .html files

Postby hydrurga » 07. December 2011 15:36

Problem solved! Your advice was indeed good Sharley, I just forgot to Shift Refresh the Firefox Cache so I was seeing the cached version of the page (oops). In the end, by a process of elimination, in order to parse .shtml files on a site, all I have to do is add the line "Options Indexes" to the configuration file e.g.:

Code: Select all
<VirtualHost *>
  DocumentRoot "C:\Web Sites\XXX\www"
  ServerName xxx.test
  <Directory "C:\Web Sites\XXX\www">
    Options Indexes
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>


and if there are files in the site that have .html extensions which I also want parsed for SSI, the format is:

Code: Select all
<VirtualHost *>
  DocumentRoot "C:\Web Sites\XXX\www"
  ServerName xxx.test
  <Directory "C:\Web Sites\XXX\www">
    Options Includes
    AddHandler server-parsed .html
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>


Thanks for the all your help with this! It's great to get it finally working. :D
hydrurga
 

Re: Server-Side Includes with .html files (XPSP3) 1.7.7 [SOL

Postby Sharley » 07. December 2011 22:38

You're welcome and thanks for the feedback. 8)

Best wishes. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 246 guests