Aaron
Aaron

Reputation: 1777

Redirect .com to .org in .htaccess

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

Answers (2)

Ani Menon
Ani Menon

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

Gumbo
Gumbo

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

Related Questions