1

I am having problems getting a virtual host to display includes. I am using XAMPP for Linux. I have tried "XBitHack on", which didn't work.

My index.html file looks like this:

<!DOCTYPE html>
<html lang="en" class="no-js">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="icon" type="image/png" href="https://shamar.org/favicon.ico">
    <meta name="description" content="">
    <meta name="verify-v1" content="jILCms9UBQLGa4vAPY5nmhxTzW8kRj12iXnxrg7zWIU=">
    <meta name="msvalidate.01" content="E553571C6477AC566A8C74B52925BFDB">
    <meta charset="UTF-8">
    <title>shamar.org</title>

        <!-- start CSS Area -->
    <!--#include virtual="includes/css.html" -->
        <!-- End CSS Area -->

    <script src="/js/daily_scripture.js"></script>

    </head>
    <body class="wv-disable">
      <header>
        <!--#include virtual="/includes/upperNavShamar.html" -->
      </header>

      <div class="site-main-container">

        <!-- Start latest-post Area -->
        <section class="latest-post-area pb-120" style="padding-top:10px;">
          <div class="container no-padding">
          <div class="row">
          <div class="col-lg-12 post-list">

          <!--   Begin Daily Script   -->
          <!--   <div class="dailyScript">   -->
          <div class="dailyScripture">
          <script>
          <!--
            writeTip();
          -->
          </script>
          </div>
          <!--   End Daily Script   -->
          </div>
          <div class="col-lg-8 post-list">
            <!-- Start latest-post Area -->
            <div class="latest-post-wrap single-sidebar-widget">

  <!--#include virtual="/includes/frontPageShamar.html" -->

  <!-- End latest-post Area -->
    </div>


  <!--#include virtual="/includes/rightColumnShamarHome.html" -->

    </div>

  <!-- start footer Area -->
    <!--#include virtual="/includes/footerShamar.html" -->
  <!-- End footer Area -->

  <!-- start JavaScript Area -->
    <!--#include virtual="/includes/javascript.html" -->
  <!-- End JavaScript Area -->

</body>
</html>

My .htaccess (that which may pertain to this):

Options +SymLinksIfOwnerMatch
# Use +SymLinksIfOwnerMatch instead of +FollowSymLinks option for security
RewriteEngine On
ServerSignature Off
Options +Includes

AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm
AddType application/epub+zip .epub
AddType application/x-mobipocket-ebook .mobi
AddType text/html .html .htm
AddHandler server-parsed .html
AddOutputFilter INCLUDES .html .shtml

The domain-related section from http-vhosts.conf:

<VirtualHost *:80>
  DocumentRoot "/home/lee/htdocs/shamarNew/"
  ServerName shamar.test
</VirtualHost>

I have several other virtual domains that work fine, except those are all .php files where here they are all .html. I know HTML does allow includes as it works on my web host. BTW, it does display the non-included text. The example above only show the Scripture JavaScript but nothing else.

Any suggestions? If other files are needed just let me know.

4
  • Presumably you aren't getting any errors output? So, the directive would not seem to be processed at all. You shouldn't need the AddHandler server-parsed .html directive (that's for old versions of Apache AFAIK). If you rename your file with a .shtml extension, does it work? To clarify, this file index.html is in the document root directory (ie. /home/lee/htdocs/shamarNew/index.html?
    – MrWhite
    Dec 15, 2020 at 17:55
  • No errors. I removed the "AddHandler" I tried renaming an include with .shtml, but that didn't work. index.html is in the document root directory
    – Lee
    Dec 15, 2020 at 18:11
  • "I tried renaming an include with .shtml" - To clarify, the file in which you have the SSI would need to have the .shtml extension, not the file you are including. ie. index.shtml. Is mod_include enabled? Restarted Apache?
    – MrWhite
    Dec 15, 2020 at 18:21
  • "the SSI would need to have the .shtml extension". Tried it but didn't work. mod_include is enabled. Apache restarted each time there is a change.
    – Lee
    Dec 15, 2020 at 18:32

2 Answers 2

1

The error was in the vhost file. Error I received: "Expected </VirtualHost> but saw </Directory>". Deleted the </Directory>, replaced it with </VirtualHost>. Everything seems to work fine now. (But I do feel stupid.)

I appreciate all your help. Thanks!

0
<VirtualHost *:80>
  DocumentRoot "/home/lee/htdocs/shamarNew/"
  ServerName shamar.test
</VirtualHost>

Your vHost is very minimal? You will need to allow .htaccess overrides in the server config, otherwise your .htaccess is simply going to be ignored (or at least some of the directives). You also need to allow access to the document root - although I assume you must be doing this somewhere already otherwise your site would not be accessible.

For example, inside your vHost container:

<Directory "/home/lee/htdocs/shamarNew/">
    AllowOverride All
    Require all granted
</Directory>

...and restart Apache.

Also, this is only the vHost for port 80 (HTTP), so I assume you are only referencing this over plain HTTP, not HTTPS. (Although you reference HTTPS in the HTML.)

9
  • Yes, I am referencing "http". I already have that in my server config file. Remember, this works for all the ".php" files, just not for ".html" includes.
    – Lee
    Dec 15, 2020 at 20:38
  • IN RE ABOVE: While these includes have a .html extension, the ones for the .php have an "inc" extension, if that makes a difference.
    – Lee
    Dec 15, 2020 at 22:31
  • "this works for all the ".php" files" - I kinda assumed you would be using PHP include() inside PHP files? If you are using SSI for PHP files, did you try enabling .html for that vHost? Same result?
    – MrWhite
    Dec 15, 2020 at 22:40
  • "While these includes have a .html extension, the ones for the .php have an "inc" extension" - that shouldn't be a problem. You can have nested includes. But it is worth testing that. Do you have any other directives in your .htaccess file?
    – MrWhite
    Dec 15, 2020 at 22:43
  • 1
    This is in my error log for XAMPP: "mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed: /index.html" But I have set it in the conf file and the .htaccess file.
    – Lee
    Dec 16, 2020 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.