Redirection : Best Method?

Hello,

I would like all my domain names, of varying name and extension, to point to a single domain name.

For example,

example.org, example.net should redirect to example.com.

What is the best way to do this? CNAME records or Apache configuration?

CNAME seems much more simple and more easy to manage, but what are the disadvantages of this method?

Hello, thanks for your reply.

I don’t have CPanel installed on the server, but I have access to the DNS records and Apache. It is currently setup so that all of the domains point to the same DocumentRoot, however this does not redirect the domain names, which is what I need.

If there is no difference in the effectiveness of both methods I think I would go for the CNAME approach, however I believe this is more of an alias than a redirect? How does this effect other things such as searching engine rankings?

Thanks. That’s great. Are there any significant overheads in using the mod_rewrite?

Aaron,

Redirect the domain names? Remove the requested domain name and substitute with ONE (preferred) domain name? If that is what you want to do, use mod_rewrite:

RewriteEngine on
RewriteCond %{HTTP_HOST} !(www\\.)?preferred\\.domain [NC]
RewriteRule .? http://www.preferred.domain%{REQUEST_URI} [L]

That will effectively wipe-out all but the preferred domain - although I’d make the [L] flag [R=301,L] so all the SE’s know that you’re making a permanent redirection so they won’t penalize you.

Regards,

DK

Aaron,

Welcome to SitePoint’s Apache forum!

I’d use cPanel’s “Parked Domain” function which modifies your DNS for the parked domains. Well, I guess I’m not sure how that’s done as it would be a simple matter to point all the VirtualHost DocumentRoot settings to the same physical directory. Six of one, half dozen of the other, IMHO. It would depend upon which you have easier access to.

Regards,

DK

Aaron,

Significant? The overhead depends upon where the mod_rewrite is located. If in the httpd.conf or httpd-vhosts.conf (equivalent) file, then only that the server must read the mod_rewrite code ONCE. If in the .htaccess, it gets read for EVERY file request. Basically, a two-liner like this will have a nil impact, though, so GO FOR IT! (It’s the long lists of 'bots that are read and parsed on every request that will slow a server.)

Regards,

DK