Reputation: 1777
I have domain.com and domain.org as aliases pointing to the same vhost. How can I use .htaccess to redirect all domain.com requests to domain.org?
Upvotes: 7
Views: 16196
Reputation: 28239
Redirects all www/non-www of domain.com
to domain.org
:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.org/$1 [R=301,L]
Upvotes: 4
Reputation: 655489
You could use mod_rewrite to do this.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^example\.org$
RewriteRule ^ http://example.org%{REQUEST_URI} [L,R=301]
This rule redirects every request that’s not addressed to example.org
to the very same.
Upvotes: 18