We help IT Professionals succeed at work.

php and shtml files appear as text on virtual server

ddantes
ddantes asked
on
Up until yesterday I was able to browse php files and other files with the .shtml extension on my virtual server, using WampServer.  Then, last night, these files began opening as text.  Localhost still displays files with .htm and .html as web pages.  I am not aware of making any changes before this occurred, and it happens with multiple browsers.
Comment
Watch Question

Greg AlexanderLead Developer

Commented:
Are you sure apache is not turned off? You may have to restart it
CERTIFIED EXPERT

Commented:
You need to have the following options in httpd.conf:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

Also, it matters where in your web server the shtml files are located.  They may have previously worked in your DocumentRoot, but not a VirtualHost (or vice-versa.)  You need to be sure that wherever you located the .shtml files, that directory is permitted to run SSI.  You use the Includes directive to do this, as follows:

<Directory C:\some\path>
  Options Includes
</Directory>
I have this problem with wamp, often times because I've restarted my computer and wamp (for whatever reason) refused to start on start-up, Make sure its running and all is green, or it will allow you to get the files but not parse them.

Author

Commented:
Thank you for your comments.  The virtual server was online, but I exited and restarted.  The issue persisted. I will check the httpd.conf for settings, but everything worked before last night.  I'll repost after checking the configuration.

Author

Commented:
This code is already in httpd.conf:  AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
I'm not sure where to check for
<Directory C:\some\path>
  Options Includes
</Directory>
or where to insert it if it is missing.
CERTIFIED EXPERT

Commented:
in httpd.conf, you should have somewhere a set of <Directory></Directory> tags which describe your server's DocumentRoot.  For instance, if your .shtml files are in C:\apache\htdocs, then you should have a Directory section referencing that in httpd.conf

You may just have one that says "<Directory />" too, which is kind of all encompassing, but you can put the Options Includes directive in there too.  It MUST be present for you to use server-side includes though.

Author

Commented:
I found two references:
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

and

<Directory "P:/Program Files/Web Publish/Maui Site 1">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Order Allow,Deny
    Allow from all

</Directory>

The pathway is correct.
CERTIFIED EXPERT

Commented:
Okay, so do .shtml files in "P:/Program Files/Web Publish/Maui Site 1" work?

That is the only place you have them permitted according to your config file.  Anything in that folder (and below) will work for SSI.  Anything outside of that will not.

And are you sure the drive letter still matches?  P: seems odd to me, but I don't run Windows, so maybe its normal.

Author

Commented:
Thank you for your comment.  shtml files in that directory (which is the correct path) did not work. So I restored a previous disk image of the drive which contains WampServer, and now they work again.  Thanks for your troubleshooting.

Author

Commented:
The problem was not related to WampServer being off line, but something in its configuration must have become corrupted.  Restoring a previous version of the files from a disk image corrected the issue.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.