.htaccesshttp-redirect

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?


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.