Using apache, I am trying to achieve the following scenario using SSI:
The following configuration in .htaccess
works fine, if I try to render the page that resides within Server1 (after commenting out the rewrite rule - RewriteRule (.*) http://172.24.0.2:80/index.html [P]
)
AddDefaultCharset UTF-8
RewriteEngine On
RewriteRule (.*) http://172.24.0.2:80/index.html [P]
## Enable server side includes
Options +Includes
# Filter .html files through mod_include first
AddType text/html .html
AddOutputFilter INCLUDES .html
The following is the SSI directive that I am trying to include:
<!--#echo var="DATE_LOCAL" -->
The problem is, when apache in Server1 renders the page, it displays the SSI directive as it is (html comment).
I think I am missing out some configuration to tell apache to interpret it, once the response comes back after redirection.
The root cause of the problem: Server1 is returning compressed content. Apache won't un-compress it to apply SSI rules by default. It can be solved with the following 2 options:
Option1:
Force apache in Server1 to refuse to support compression using the following option in .htaccess:
RequestHeader unset Accept-Encoding
My updated .htaccess
file looks like the following:
RequestHeader unset Accept-Encoding
AddDefaultCharset UTF-8
RewriteEngine On
RewriteRule (.*) http://172.24.0.2:80/index.html [P]
## Enable server side includes
Options +Includes
# Filter .html files through mod_include first
AddType text/html .html
AddOutputFilter INCLUDES .html
Option2:
Uncompress the incoming data with mod_deflate
module using the following option in .htaccess:
SetOutputFilter INFLATE;DEFLATE
My updated .htaccess
file looks like the following:
AddDefaultCharset UTF-8
RewriteEngine On
RewriteRule (.*) http://172.24.0.2:80/index.html [P]
## Enable server side includes
Options +Includes
# Filter .html files through mod_include first
AddType text/html .html
AddOutputFilter INCLUDES .html
SetOutputFilter INFLATE;DEFLATE
The excerpts in apache config for the above solution would look like the following:
<Location />
SetOutputFilter INFLATE;DEFLATE;INCLUDES
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|css|js|zip|gz)$ no-gzip dont-vary
</Location>