1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to redirect all urls to new domain.

Discussion in 'Black Hat SEO' started by Rays90, Jul 29, 2016.

  1. Rays90

    Rays90 Newbie

    Joined:
    Jul 20, 2016
    Messages:
    22
    Likes Received:
    2
    Hello,

    How to redirect to new domain, the site structure is the same. I want all urls, eg: domain1.com/blah-blah to redirect to domain2.com/blah-blah.

    Thanks
     
  2. Rays90

    Rays90 Newbie

    Joined:
    Jul 20, 2016
    Messages:
    22
    Likes Received:
    2
    I found this answer in google but couldn't figure how to do it. Can any help explain more detail please.

    Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

    ----------
    Options +FollowSymLinks -MultiViews
    # Turn mod_rewrite on
    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTP_HOST} ^(www\.)?a\.fr$ [NC]
    RewriteRule ^ http://a.com%{REQUEST_URI} [R=301,L]
    ------------

    http://stackoverflow.com/questions/18855934/redirect-to-another-domain-but-keep-rest-of-url

    Thanks.
     
  3. CoMBoZo

    CoMBoZo Junior Member

    Joined:
    Sep 30, 2014
    Messages:
    101
    Likes Received:
    4
    Gender:
    Male
    Go to " redirects " on your cpanel account, and redirect your domain to your new destination
     
  4. Rays90

    Rays90 Newbie

    Joined:
    Jul 20, 2016
    Messages:
    22
    Likes Received:
    2
    Yes, i have tried that. I even tried wild card which was suppose to do what I want but it doesn't do it. It only redirects when going to homepage, going to individual pages, it doesn't redirect.

    So, can anyone actually help me with doing the code above, where is httpd.conf in cpanel, i'm using shared hosting?

    Thanks
     
  5. juanpopo

    juanpopo Power Member

    Joined:
    Mar 13, 2010
    Messages:
    639
    Likes Received:
    100
    if you are using worpress you can 301 your domains, can be inconvinient if you have too many pages...
     
  6. ZBf5vQTGshZ5ZeKUspAO

    ZBf5vQTGshZ5ZeKUspAO Newbie

    Joined:
    Mar 3, 2014
    Messages:
    36
    Likes Received:
    9
    I've personally done this easily using Cloudflare with wildcards.

    https://support.cloudflare.com/hc/en-us/articles/200172286-How-do-I-perform-URL-forwarding-or-redirects-with-CloudFlare-

    In your page rules, set is up as follows:

    The solution is to use variables. Each wildcard corresponds to a variable when can be referenced in the forwarding address. The variables are represented by a $ followed by a number. To refer to the first wildcard you'd use $1, to refer to the second wildcard you'd use $2, and so on. To fix the forwarding from the root to www in the above example, you could use the same pattern:

    example.com/*

    You'd then setup the following URL for traffic to forward to:

    http://www.example.com/$1

    In this case, if someone went to:

    example.com/some-particular-page.html

    They'd be redirected to:

    http://www.example.com/some-particular-page.html



    NOTE: Traffic must be passing through CloudFlare for Page Rules to work, if you are using CloudFlare for DNS only then Page Rules will not be active.
     
  7. clevelandslim

    clevelandslim Jr. VIP Jr. VIP

    Joined:
    Nov 15, 2008
    Messages:
    1,972
    Likes Received:
    191
    Try out this. It will be usefull for you.
    1. Transfer old domain to new hosting company.
    2. Hosted old domain in a new hosting company.
    3. At this point, both domains are hosted in new hosting company in which I have a full access. Then you will add old domain in GWT.
    4. After adding old domain in GWT, You will set up 301 redirect for old domain.
    5. Submit change of address form from old domain account in GWT.
     
  8. TheSEOWizard

    TheSEOWizard Power Member

    Joined:
    Aug 20, 2011
    Messages:
    548
    Likes Received:
    156
    Occupation:
    SEO, PBN, Website et all
    Location:
    PBN World/SEO Land
    If you have the patience and would like to keep the old domain intact, it might also be possible to redirect individual URLs using a plugin such as Redirection. I have never tried it out though and am not very sure of the same. You might be able to do the same using htaccess.
     
  9. Rays90

    Rays90 Newbie

    Joined:
    Jul 20, 2016
    Messages:
    22
    Likes Received:
    2
    I figured it out, it was as simple as using this code in htaccess file.

    RewriteEngine on
    RewriteRule ^(.*)$ http://newdestination.com [R=permanent,L]

    to redirect the whole site with same structure, just add $1 so it becomes

    RewriteEngine on
    RewriteRule ^(.*)$ http://newdestination.com/$1 [R=permanent,L]

    No need to ever use any plugins or use any redirect feature in cpanel, this code works best.
     
  10. iegyi

    iegyi BANNED BANNED

    Joined:
    Aug 15, 2011
    Messages:
    23
    Likes Received:
    0
    Gender:
    Male
    Go to " redirects " on your cpanel account, and redirect your domain to your new destination