Results 1 to 8 of 8

Thread: Apache HTML include files problem

  1. #1
    Join Date
    Dec 2005
    Location
    U.K.
    Beans
    168
    Distro
    Ubuntu 12.04 Precise Pangolin

    Apache HTML include files problem

    I seem to be unable to use the html
    Code:
    <!--#include virtual="test.txt" -->
    I have tried following the advice in this thread http://ubuntuforums.org/showthread.php?t=1510098 but it makes no difference.

    The file is there, but the line is delivered to the browser as-is.

    Using Lucid and a new install of apache 2.2 from the repository.

    Any help greatly appreciated.

    TIA

    Nick

  2. #2
    Join Date
    Apr 2007
    Location
    Glasgow
    Beans
    308
    Distro
    Ubuntu

    Re: Apache HTML include files problem

    Hi Nick,

    Please confirm your apache configuration includes the following lines -->

    Code:
    LoadModule include_module modules/mod_include.so
    ...
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    ...
    <Directory "/var/www/...">  # Wherever you want the includes to be active
      Options ... +Includes ... # And other options you want
    Please then confirm that the apache error_log -- /var/log/apache2/error_log (or wherever it's located, i don't have an ubuntu machine to hand to check) contains no errors when you restart apache.

    Finally confirm that test.txt is in the same directory (this is what you have specified with your virtual= path) as the file you are calling the include from, whilst also verifying that filename ends in .shtml

    This covers pretty much everything, unless you are using a MAC (mandatory access controls) implementation such as AppArmour or SELinux.

  3. #3
    Join Date
    Dec 2005
    Location
    U.K.
    Beans
    168
    Distro
    Ubuntu 12.04 Precise Pangolin

    [Solved] Re: Apache HTML include files problem

    Many thanks.

    I did have those settings correct, and it turns out that it was down to my stupidity. I thought that the file to be included needed the shtml extension, rather than the main file.

    Thanks again

    Nick

  4. #4
    Join Date
    Apr 2007
    Location
    Glasgow
    Beans
    308
    Distro
    Ubuntu

    Re: Apache HTML include files problem

    Glad it was an easy fix.

    P.s. nothing stupid about it, the configuration to instruct apache is necessarily complex for such a feature-full application, it's unreasonable to expect to get a handle on all parts of the configuration first time round

  5. #5
    Join Date
    Dec 2005
    Location
    U.K.
    Beans
    168
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Apache HTML include files problem

    The stupid part is that I should have known - I went through this with php scripts (although in a much shorter time)!

  6. #6
    Join Date
    Apr 2007
    Location
    Glasgow
    Beans
    308
    Distro
    Ubuntu

    Re: Apache HTML include files problem


  7. #7
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    IncludesNOEXEC

    One reason to use SSI over PHP is improved security, so a refinement in that regard to @craigp84's pointer is to be sure to use IncludesNOEXEC rather than Includes.

    Code:
    LoadModule include_module modules/mod_include.so
    ...
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    ...
    <Directory "/var/www/...">  # Wherever you want the includes to be active
      Options ... +IncludesNOEXEC ... # And other options you want
    That allows you to include text and html from other files without the risk of running scripts.

  8. #8
    Join Date
    Dec 2005
    Location
    U.K.
    Beans
    168
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Apache HTML include files problem

    Thanks for that tip, although as I'm generating the included files, there *should* be no risk of any script running.

    Nick

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •