Redirect .com to .org in .htaccess
Question
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?
Solution
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.
OTHER TIPS
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]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow