Sure! Since a subdomain is normally “pointed” at a subdirectory of the domain, it’s safe to simply use mod_rewrite in the domain’s .htaccess to check for the existance of the urllevel1 directory then redirect to HTTP://SUB1.domain.com (with the remainder of the original URI after urllevel1/ has been removed).
<IfModule mod_rewrite.c>
[color=red][standard rant #4][indent]The definition of insanity is to repeatedly do the same thing expecting
a different result. Asking Apache to confirm the existence of ANY module with an
<IfModule> ... </IfModule> wrapper is the same thing in the webmaster world.
DON'T ACT INSANE! If you don't know whether a module is enabled, run the
test ONCE (without the wrapper) then delete it permanently as it is EXTREMELY
wasteful of Apache's resources (and should NEVER be allowed on a shared
server).[/indent][/standard rant #4]
Uh, simply test once to see whether your mod_rewrite is enabled then delete the <IfModule> and </IfModule> wrapper code.[/color]
RewriteEngine On
RewriteBase /
[color=red]Remove this as it's just plain not needed (and can confuse you if you have a mod_alias redirection).[/color]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} /index.html !-f
[color=red]Don't forget the space after the variable you're testing against - then remove the leading /
for Apache 2.x servers (and escape the dot character in the regex).[/color]
RewriteCond %{REQUEST_FILENAME} /index.php !-f
[color=red]Ditto the above.[/color]
RewriteRule . index.php [L]
[color=red]What about the domain-only request? You've required a single character (the / doesn't count)
so you've got to rely on the DirectoryIndex to request index.php. Use a ? after the dot (optional character) so the regex will ALWAYS be true and the redirection will take effect.[/color]
</IfModule>
[color=red]As above.[/color]
What do I need to add here in order to achieve my theory?
Is this what your new CMS requires? If so, IMMEDIATELY after the RewriteEngine on …
# in domain.com's Document Root (so sub1.domain.com can't access it)
# redirect to HTTP://SUB1.domain.com (with the remainder of the original URI after urllevel1/ has been removed)
RewriteRule ^subdir1/(.*)$ http://sub1.domain.com/$1 [R=301,L]
# Here, you DO want to capture the entire URI [i]after[/i] the subdir so (.*)
will do that for you and the domain change will prevent looping.