Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
It works. The problem is, when I add new sites under the shared account (cpanel), they get redirected from httx://www.newsite1.com to httx://www.example.com/newsite1 and httx://www.newsite2.com to httx://www.example.com/newsite2, etc.
How can I exclude these new sites from being redirected? I tried all kinds of rules to exclude the folders newsite1 and newsite2, but nothing works.
# If request does not include newsite1
RewriteCond %{HTTP_HOST} !newsite1 [NC]
# And does not include newsite2
RewriteCond %{HTTP_HOST} !newsite2 [NC]
# Run the routine
RewriteCond %{HTTP_HOST} !^(.*)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
However, I do not use cPanel and don't know how it might interfere.
...
# If request does not include newsite1
RewriteCond %{HTTP_HOST} !newsite1 [NC]
# And does not include newsite2
RewriteCond %{HTTP_HOST} !newsite2 [NC]
# Run the routine
RewriteCond %{HTTP_HOST} !^[b]www[/b]\.example\.co[b]m$[/b]
RewriteRule [b](.*)[/b] http://www.example.com/$1 [R=301,L]