SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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:
    Code:
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. That's great. Are there any significant overheads in using the mod_rewrite?

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •