In an SSI include, can the file being included be redirected in an .htaccess file

.htaccessapache-2.2redirectserver-side-includes

I have some old html pages that have SSI includes in them to include certain html in all the pages.

So, the SSI looks something like this:

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

But I want to move that included file from /includes/noNav/footercode.html to /includes/footercode.html so I implemented a redirect in an .htaccess file like this:

# Redirect permanent /includes/noNav/footercode.html  http://intranet.myorg.org/includes/footercode.html

But now I get errors saying "unable to include "/includes/noNav/footercode.html" in parsed file" So, do redirects not work on included files?

Also, if I browse directly to the old path, it will correctly redirect me. But it fails if the path is included.

Best Answer

The SSI is parsed as part of the apache SSI module and does not make web requests back to Apache in order to retrieve the file. As it does not use HTTP back to Apache to retrieve the files specified by #include, no rewrite or redirect rules are applied.

The virtual= directive finds a file starting at ServerRoot, while the file= directive finds a file in the same directory as the current page.