Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have multiple web-apps running on a server using different technologies.

  • java
  • php (wordpress)
  • python (trac)

They are all front-ended with Apache 2.2. My question is does anyone know a good way to wrap all these web apps with a common template (header/footer).

I was looking into mod_layout, but the documentation is quite limited and I was unable to get even the simplest example to work.

I also looked at mod_include, but I'm not sure if that is a good idea.

share|improve this question

migrated from stackoverflow.com Aug 21 '09 at 22:22

This question came from our site for professional and enthusiast programmers.

    
I just got a simple example of mod_layout working, the problem was mod deflate had to be disabled –  delux247 Aug 20 '09 at 18:41
    
One more thing that I figured out is that if you want your header/footers to be java servlets then you need to use mod_jk and JkEnvVar to pase the mod_layout environment variables. - musc.edu/webserver/mod_layout.html#_1_15 - tomcat.apache.org/connectors-doc/reference/apache.html –  delux247 Aug 21 '09 at 14:57

2 Answers 2

up vote 2 down vote accepted

You can force all pages of a certain extension to include a header and footer by setting it out in the httpd.conf of the server, or just in the .htaccess of each particular directory/site with the append and prepend directives like so:

<FilesMatch "\.html$">
php_value auto_prepend_file /path/to/header.html
php_value auto_append_file /path/to/footer.html
</FilesMatch>

The above will match .html pages and will force include /path/to/header.html before the page content as well as /path/to/footer.html after the page.

Just remove the FilesMatch lines if you want to force it on all pages.

share|improve this answer

Use similar templates for all your applications. Simply slapping extra HTML onto the beginning and end of a page will give you nonconformant output, which is likely to break layout within applications.

WordPress and Trac both have highly capable theming systems. Use them.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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