Redirecting traffic from subdomain to domain

Discussion in 'Site & Server Administration' started by bluearrow, May 12, 2008.

  1. #1
    I'm going to move a site from a subdomain to new domain. How to redirect traffic using cpanel ? or its better use php header redirection ?


    I have another site which has some missing pages and
    i want to missing pages redirect to the home page. How you do it using cpanel ?


    .
     
    bluearrow, May 12, 2008 IP
  2. djacobs

    djacobs Well-Known Member

    Messages:
    238
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    140
    #2
    cPanel is a control panel, it doesn't redirect traffic.

    You should just edit your DNS so that the subdomain redirects to the domain. You should be able to use cPanel to edit this configuration.

    This makes much more sense than using PHP or Apache redirect since it's less overhead.
     
    djacobs, May 14, 2008 IP
  3. bluearrow

    bluearrow Well-Known Member

    Messages:
    1,339
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Well I used a 301 redirect. Had to do for more 250 pages line by line. But still it was the best option i guess.

    .
     
    bluearrow, May 14, 2008 IP
  4. xous

    xous Active Member

    Messages:
    173
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Hi,

    lol, ouch...

    You should have done the redirect with a .htaccess file.

    RewriteEngine on
    rewritecond %{http_host} ^subdomain.example.net [nc]
    rewriterule ^(.*)$ http://www.example.net/$1 [r=301,nc]

    DNS doesn't do redirects either. I assume you mean making the subdomain a CNAME pointing to the domain. This would not work unless the sub-domain is setup as an alias in the vhost configuration and it would still not be redirecting but showing the same content with the sub-domain in the address url.
     
    xous, May 14, 2008 IP
  5. bluearrow

    bluearrow Well-Known Member

    Messages:
    1,339
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #5
    I did with .htaccess file but i redirect 301 each url to save at least little of serp.


    .
     
    bluearrow, May 14, 2008 IP
  6. djacobs

    djacobs Well-Known Member

    Messages:
    238
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    140
    #6
    Incorrect, you're making a generalization of DNS software. There's more than BIND.
    Just to give you an example, when I used Namecheap to host my DNS, I can re-direct a subdomain to another domain.
     
    djacobs, May 15, 2008 IP
  7. xous

    xous Active Member

    Messages:
    173
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Ahh, but that is different - it uses both DNS and HTTP. There is no method in the DNS RFCs for allowing redirects. The redirect is done via http 301 redirect.

    In your example what happens with namecheap is that when you set up a redirect they point your domain to one of their web servers via a standard A record.

    This web server is configured to do nothing but look up the URL it should redirect to for your host name and then do the redirect.

    I know this seems like a very fine line but it is extremely important to understand when attempting to diagnose issues.

    A similar feat can be accomplished if you were to add the domain (or sub-domain) as an add-on domain in cPanel and then placed a .htaccess file in the add-on domains folder.
     
    xous, May 15, 2008 IP