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

Code for 301 redirect

Discussion in 'Black Hat SEO' started by rkss, Sep 8, 2016.

  1. rkss

    rkss Registered Member

    Joined:
    Aug 23, 2016
    Messages:
    52
    Likes Received:
    9
    Hi, I'm about to do a 301 redirect. All pages of site A should go straight to the Homepage of site B.

    Assuming site B's URL is http://apple.com, just want to confirm that this .htaccess code is correct:

    Redirect 301 / http://apple.com

    Also, is it better to use the www version of the domain (eg. http://www.apple.com), or without is fine?
     
  2. Hawkster

    Hawkster Jr. VIP Jr. VIP

    Joined:
    Jun 22, 2013
    Messages:
    3,504
    Likes Received:
    3,721
    Gender:
    Male
    Occupation:
    Listen to everyone - Follow no-one
    Location:
    UK
    Home Page:
    This is what someone gave me on a thread i started recently

    "Here is everything you need inside your .htaccess (talking about old site):

    RewriteEngine on
    RewriteRule ^/file\.html$ - [L]
    RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

    Replace file with name of file you want excluded (and extension if it's not html). Also newdomain.com obviously.
    Everything from old site will be redirected to new one with exact URL requested (old.com/url -> new.com/url) with the exception of "file.html"

    Make a backup of .htaccess just in case (always good idea)."
     
  3. smatysik

    smatysik Newbie

    Joined:
    Apr 9, 2015
    Messages:
    39
    Likes Received:
    1
    Home Page:
    this
    RewriteRule ^(.*)$ http://apple.com/$1 [R=301,L]