well the example i gave was very simple. the point is mod_rewrite is the tool to use for stuff like this.
you can use mod_rewrite in .htaccess files too.
you dont have to hardcode every url, mod rewrite supports regular expressions and has the ability to capture parenthesized matches and then use them as backreferences
this would check if the current requested url exists or not, if not, it would do an external redirect into the group2 folder. im not sure how to check if the url its redirecting to exists or not, but i know it can be done. you can look at the manual, prob look at subrequests.
this would go in a .htaccess in your groups dir
RewriteEngine on
RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !-f
RewriteRule (.*) http://%{SERVER_NAME}/groups/group2/$1 [R] # R means external redirect
if using the above, you would want to put this in your group2 directory to prevent an endless redirection loop
RewriteEngine off
and an alternative, is you could do an INTERNAL rewrite for failing urls to a php script which would handle things. your prob much more comfortable w/ php, and it could make it much easier for you
RewriteEngine on
RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !-f
RewriteRule .* groups_file_handler.php #internal rewrite
<?php
$request = $_SERVER['REQUEST_URI'];
// parse it
// check if the file exists in some other directory
if (yes) {
header('Location: other location');
} else {
header(); // send 404 not found, or do something else
}
?>