shtml, virtual includes and php

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

shtml, virtual includes and php

Postby charpaula » 17. November 2008 23:43

The following configuration runs in the production environment

.htaccess
AddHandler application/x-httpd-php .shtml

index.shtml
<!--#include virtual="/commonfiles/header.htm" -->

<?php
PHP code
?>

*********************
Just downloaded today - Under Vista - XAMPP 1.6.8 installed (no modifications) on USB stick via PortableApps

The PHP code executes but in place of the includes I get the error directive message which of course means the directory is not found.

Directory - xampp/htdocs/xampp/commonfiles/
Direcory - xampp/htdocs/xampp/index.shtml

********************

Not sure what I have to change in .htaccess, config or? to get the virtual includes to work.

Changing the includes is not an option as this is the only way they work in the production environment

Any ideas or suggestions would be greatly appreciated
charpaula
 
Posts: 3
Joined: 17. November 2008 23:24

Postby Sharley » 18. November 2008 00:02

How did you install to a USB?

This from the readme-en.txt file and often overlooked:
* QUICK INSTALLATION:

[NOTE: Unpack the package to your USB stick or a partition of your choice.
There it must be on the highest level like E:\ or W:\. It will
build E:\xampp or W:\xampp or something like this. Please do not use the "setup_xampp.bat" for an USB stick installation!]

Running the bat file will create paths in your conf and ini files which may conflict your actual USB paths.



Your files are best placed in a folder within the htdocs root folder to save confusion and to keep all your own files in the one path location:
xampp\htdocs\yourfiles\

http://localhost/yourfiles/index.shtml
with included files within the yourfiles/commonfiles folder so the path to the includes should be found.

Using the xampp folder to put your own files is not recommended - also a URI would be http://localhost/xampp/index.shtml for files in the xampp folder, best leave the xampp folder for exclusive use of XAMPP files.

This thread although related to DreamWeaver has some tips on include paths for php.
http://community.apachefriends.org/f/viewtopic.php?t=32034
The php.ini file mentioned is in the apache\bin folder

See how that goes.
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

Postby charpaula » 18. November 2008 01:08

For installation followed instructions here:
http://portableapps.com/apps/developmen ... ad_details

and xampp_setup.bat was not run

http://localhost/xampp/ gets Welcome

http://localhost/mydirectory/index.shtml

PHP executes without a problem so it is finding that directory... still getting the [an error occurred while processing this directive] for the virtual includes

The files to include sit in mydirectory/commonfiles/
and
http://localhost/mydirectory/commonfiles/header.htm displays what should be included
charpaula
 
Posts: 3
Joined: 17. November 2008 23:24

Postby Sharley » 18. November 2008 01:28

The clues are in your apache error log file?
xampp\apache\error.log

When I replicated your setup the error log told me:
Code: Select all
File does not exist: C:/xampp/htdocs/commonfiles

unable to include "/commonfiles/header.htm" in parsed file C:/xampp/htdocs/mydirectory/index.shtml


Changed the path (dropped the front forward slash) to:
<!--#include virtual="commonfiles/header.htm" -->
and it then parsed both the ssi and the php - no errors.


So to keep your ssi code the same as your production server, you would have to do this:

Place your index.shtml and your .htaccess file in the htdocs folder (the Apache server's DocumentRoot, equivalent to your web root directory on the production server) and also create your folder commonfiles in there for your include header.htm file.

Then you would use this URI:
http://localhost/index.shtml

Note, you would always have to include the index.shtml in the URI unless you rename or delete the existing index.php in the htdocs folder.

Then simply typing http://localhost would give you your index file.
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

Postby charpaula » 18. November 2008 16:13

Thank you for your responses - xampp\apache\error.log didn't exist, checked the error directory then finally the logs directory and there it was.

Production system requires the leading slash, so I can't remove it from the virtual includes... knowing the path problem the fix was easy

The following works -
index.shtml with
<!--#include virtual="/commonfiles/header.htm" -->

.htaccess
AddHandler application/x-httpd-php .shtml

Directory setup
xampp/htdocs/mydirectory/
xampp/htdocs/commonfiles/ all includes and script files reside here

http://localhost/mydirectory provides the index.shtml page with includes, all javascript and php correctly parsed.

Easy enough for the test bed to have the virtual include directory a sibling rather than child of mydirectory

Thank you very much for your help... I should have searched the other apache directories for the error.log and would have resolved this myself. But hopefully this will help someone else with SSI issues
charpaula
 
Posts: 3
Joined: 17. November 2008 23:24


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 36 guests