We have a server that is configured to serve several sites.
One of these sites is a WordPress site, and some of its pages are really Java web applications hosted by Tomcat. The Java web applications make a request to localhost to get the headers and footers so they when their pages are loaded, everything matches the WordPress parts of the site.
This has been causing some interesting configuration challenges lately, as we have also recently tried implementing "default" sites to catch traffic that apache has no other config for.
What happens now is that when the Java applications request
header.php from localhost, the default site (whose ServerName is localhost) returns nothing, because there is no such file in the directory where the default site's content resides.
I tried fixing this with a redirect, so that the Java application would be redirected to the correct URL for the header like this:
RewriteEngine on RewriteRule ".*header\.php" "http://site1.mycompany.com/common-files/header.php" RewriteRule ".*footer\.php" "http://site1.mycompany.com/common-files/footer.php"
This fixed things slightly: Now when I try to load a Java-based page, I don't get an error, but I get:
Found. The page has moved here
(where "here" is a link to header.php)
This is still a problem since I need the content of header.php, not link to the header.php.
Is there some way to make this more seamless so that the Java applications don't even know they've hit a redirect?
Ideally, I'd modify the Java applications to handle this a little better, but that's out of scope (not my applications, not my authority to go changing them).