We have two main subdomains on our site: www.example.edu and php.example.edu. Virtually all of our content is on www.example.edu, but there are a few standalone apps hosted on php.example.edu. www.example.edu is maintained by non-technical users via a CMS that forces root-relative URLs in most cases. We would like to include departments' navigation links in their apps on php.example.edu, but those links obviously don't work as root-relative URLs. We would like to avoid server-side parsing/rewriting of sidenav files.
What we would like to do is to replace all 404s on php.example.edu with 301s to the same path on www.example.edu. I've tried a few different RewriteCond/RewriteRule setups, most recently
RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^(.*) http://www.example.edu/$1 [R=302,L]
but none of them have worked yet, either ending in false-positives or 500 errors. Any suggestions?