Most examples show how to redirect all subdomain traffic to a primary domain, maintaining the directory structure. I actually don’t want this. I want to redirect all subdomain traffic (the site is going away) to the primary domain. This is not working:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/ [R=301,L]
What happens, is if you go to this:
http://sub.newdomain.com/some/path/
You get this:
http://www.newdomain.com/some/path/
I want it all to go to the root.
How about a simple 301 redirect in the apache config file for the subdomain?
To redirect ALL files on your domain use this in your
.htaccess file if you are on a unix web server:
and another example
If you need to redirect http://mysite.com to
http://www.mysite.com and you’ve got mod_rewrite enabled on
your server you can put this in your .htaccess file:
EDIT: If you want to use this, just remove the $1 from the rules in the sample link provided if the first option above does not work.
or this:
These excerpts from here