Domain Manage

redirect help

Discussion in 'Website Design' started by diablo, Jan 25, 2016.

  1. diablo

    diablo Well-Known Member

    Joined:
    Nov 2005
    Posts:
    1,567
    Likes Received:
    28
    I want to redirect every page from an old domain to one page on a new domain.

    I've found this code:
    ## Each and every page on old domain redirects to single page
    ## By appending question mark to new domain, query strings are removed
    RewriteEngine on
    RewriteCond %{HTTP_HOST} old\.com$
    RewriteRule .* http://www.new.com/? [L,R=301]

    If I'm redirecting olddomain.co.uk to newdomain.co.uk do I replace old\.com with olddomain\.co.uk and www.new.com with www.newdomain.co.uk?
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
     
  3. Adam H

    Adam H Well-Known Member Exclusive Member

    Joined:
    May 2014
    Posts:
    1,047
    Likes Received:
    84
    Should get away with something like this in your old domains root htaccess :

    RewriteEngine On
    RewriteRule ^(.*)$ http://newdomain.com/ [R=301]
     
  4. diablo

    diablo Well-Known Member

    Joined:
    Nov 2005
    Posts:
    1,567
    Likes Received:
    28
    Thanks Adam. Old domain is no longer live. I was hoping to put the code in new domains .htaccess if possible.
     
  5. seemly

    seemly Active Member

    Joined:
    Feb 2011
    Posts:
    973
    Likes Received:
    39
    The new domain has no knowledge of the old domains existence.
    The redirect script has to be forwarding FROM the old domain TO the new domain.
     
    • Like Like x 1
  6. Adam H

    Adam H Well-Known Member Exclusive Member

    Joined:
    May 2014
    Posts:
    1,047
    Likes Received:
    84
    Are you redirecting the old domain via registrar DNS instead ? If so is it a wild card redirect which redirects all inner URL structures ? Id still personally point the old domain to a hosting account as an addon domain and then use the htaccess, give your alot more control over everything.

    If your not and the old domain is actually not being used at all... eg its expired or something then there is no way of redirecting old URL's .
     
  7. diablo

    diablo Well-Known Member

    Joined:
    Nov 2005
    Posts:
    1,567
    Likes Received:
    28
    At the moment I have parked the old domain on the new domain and redirected it to the new one. That works fine for the domain itself (as in www.olddomain.co.uk goes to www.newdomain.co.uk), but pages on the old domain throw up a 404 error page.

    I've done the above via the Parked Domain icon on the new domain's cPanel.

    Although the old domain is no longer live, it still gets traffic from search engines (obviously that will dry up over time, but meanwhile I don't want the eror page showing).
     
  8. dazc United Kingdom

    dazc Active Member

    Joined:
    Dec 2008
    Posts:
    205
    Likes Received:
    5
    Use the addon domain option instead.
     
  9. Adam H

    Adam H Well-Known Member Exclusive Member

    Joined:
    May 2014
    Posts:
    1,047
    Likes Received:
    84
    Yeah as Daz and I said , use addon domain. It will then create a folder for you to add the .htaccess, it will give you much more control over what gets redirected and what doesnt.

    The way your doing it at the moment isnt a wildcard redirect or anything, its root to root.
     
    • Like Like x 1
  10. diablo

    diablo Well-Known Member

    Joined:
    Nov 2005
    Posts:
    1,567
    Likes Received:
    28
    Brillliant! Thanks Daz and Adam.

    And what code do I put in the .htaccess for the old domain?
     
  11. Adam H

    Adam H Well-Known Member Exclusive Member

    Joined:
    May 2014
    Posts:
    1,047
    Likes Received:
    84
    I think the code I posted at the top will do it but if not post again and ill dig out what im using on some of my sites.

    Another one I use is :

    redirectMatch 301 ^/ http://www.newdomain.co.uk/
     
  12. dazc United Kingdom

    dazc Active Member

    Joined:
    Dec 2008
    Posts:
    205
    Likes Received:
    5
    I think this is the technically correct way of doing it.

    This is useful if you want the root domain to redirect to the new root domain only so you can then add individual redirects below?

    For instance, if you combine two sites but the permalink structure isn't compatible. (just going on what I've used before - not 100% certain).


    This is a useful list of rules which is handy to have bookmarked btw
    https://github.com/phanan/htaccess

    I haven't tested many of them but it's a good place to start. I've yet to find a reliable reference where every single example works 100% of the time. There will always be oddities in host set-up, software iterations and so on.
     
    • Like Like x 1
    Last edited: Jan 26, 2016
  13. Adam H

    Adam H Well-Known Member Exclusive Member

    Joined:
    May 2014
    Posts:
    1,047
    Likes Received:
    84
    You absolutely right, just released ive used it on a site which i redirect ALL requests to a single page rather than retaining the same URL structure. Apologies diablo, first one should do it, second is something different.
     
    • Like Like x 1
  14. diablo

    diablo Well-Known Member

    Joined:
    Nov 2005
    Posts:
    1,567
    Likes Received:
    28
    Really appreciate the help.

    And it's working a treat!
     
    Last edited: Jan 26, 2016

Share This Page