I am trying to write a rule to permenantly redirect a domainname to another domain name
RewriteCond %{HTTP_HOST} ^www.companyname1.com$
RewriteRule ^(.*)$ http://www.companyname2.com/$1 [R=301,L]
This only works if the user remembers to type in www, if the user does not type in www in the url, the page will load but the image links will be broken.
Does anyone know how to adjust the above rule to it works with and without www?
I am using a LAMP configuration, apache 2 on redhat.
You can supply several optional Rewrite-Conditions with [OR]:
This should do the trick. The first Rewrite-Condition fires, if www is present, the second one fires, if www has been forgotten.