I'm running apache (2.2.14) with a reverse proxy setup using mod_rewrite. A second apache using mod_php has any PHP proxied.
The issue I have is when a URI for /~user expands the DirectoryIndex to match index.shtml, the mod_rewrite rule hands off the expanded /~user/index.shtml to apache via a subrequest pass through and apache fails to execute the server side includes portion of the index.shtml
Here is a mod_rewrite debug logs of showing the expansion of URI /~mroch containing index.shtml:
initial] (1) pass through /~mroch/
subreq] (2) init rewrite engine with requested uri /~mroch/index.html
subreq] (3) applying pattern '\.(html|htm|shtml)$' to uri '/~mroch/index.html'
subreq] (1) pass through /~mroch/index.html
subreq] (2) init rewrite engine with requested uri /~mroch/index.htm
subreq] (3) applying pattern '\.(html|htm|shtml)$' to uri '/~mroch/index.htm'
subreq] (1) pass through /~mroch/index.htm
subreq] (2) init rewrite engine with requested uri /~mroch/index.shtml
subreq] (3) applying pattern '\.(html|htm|shtml)$' to uri '/~mroch/index.shtml'
subreq] (1) pass through /~mroch/index.shtml
initial] (2) init rewrite engine with requested uri /~mroch/Marie-Zocodover.jpg
initial] (3) applying pattern '.*' to uri '/~mroch/Marie-Zocodover.jpg'
initial] (3) applying pattern '\.(gif|jpg|jpeg|png|tiff|css|js|ico|pdf)$' to uri '/~mroch/Marie-Zocod
over.jpg'
initial] (1) pass through /~mroch/Marie-Zocodover.jpg
Here are the mod_rewrite rules in httpd.conf. I am sure my rules and comments can be improved on, but for the most part they are working ok outside of this SSI issue. I do appreciate any comments.
ProxyRequests Off
ProxyPassReverse / http://130.191.3.5:88
ProxyPreserveHost On
ProxyMaxForwards 2
RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 3
RewriteEngine On
# Don't match .php
# Subrequests match html|htm|shtml when expanding DirectoryIndex
# Don't match .shtml on subrequests - SSI fails to work - why?
RewriteRule \.(gif|jpg|jpeg|png|tiff|css|js|ico|pdf)$ - [L,NC,NS]
RewriteRule \.(html|htm|shtml)$ - [L,NC]
RewriteRule \.(aiff|mpeg|class|data|down|docx|java|pptx|asp|zip)$ - [L,NC,NS]
RewriteRule \.(.|.[a-z]|.[a-z0-9][a-oq-z0-9])$ - [L,NC,NS]
# Bypass slower rules for .php files
RewriteCond %{IS_SUBREQ} false
RewriteRule (\.php) http://130.191.3.5:88%{REQUEST_URI} [QSA,P]
# expand dept|faculty index pages
RewriteCond $1 ^/(dept|faculty)/(.*/$)
RewriteCond %{DOCUMENT_ROOT}$1index.html -f [OR]
RewriteCond %{DOCUMENT_ROOT}$1index.htm -f
RewriteRule (.*) - [L,NS]
# URIs that need to list directory contents and don't use php
# by allowing rewrite subreq to match here
# also used by /doc for .htaccess ErrorDocument
RewriteRule /(~avir|doc/|iso/) - [L]
# Rescan URIs rewritten by apache's core from path to path/
# that don't contain index.php after rewriting by rewrite subreq
# expands (.*) to the existing DirectoryIndex (.html|.htm|.shtml)
RewriteCond $1 !\.php
RewriteRule /~(.*) - [L]
RewriteRule ^/(cgi-bin|manual/|server-status) - [L,NS]
# Anything not matched above proxyied
RewriteRule ^/(.*) http://130.191.3.5:88/$1 [QSA,P]