Forum Moderators: phranque
RewriteEngine on
RewriteBase /RewriteCond %{HTTP_HOST}!^((www¦example).example.com¦example.com)$
RewriteRule (.*) [example.com...] [R=301,L]
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^((www¦example)\.)?example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
If you've placed this in a htaccess file in the root directory of all of the domains/subdomains, then it should do the trick. Don't forget to change the broken pipe (¦) character to a solid one before using it, this board has a funny habbit of replacing some characters ;-) If you have this in a httpd.conf, then you don't need the RewriteBase directive and the RewriteRule should look like this:
RewriteRule [b]/[/b](.*) http://example.com/$1 [R=301,L]
And finally if you did not have the mod_rewrite enabled, or if you're using these rules in a htaccess file you might need to be sure that the FollowSymLinks option is enabled somewhere, to be on the safe side add it to the top of the rules.
See the mod_rewrite documentation [httpd.apache.org] for details on the different comments.