Code for 301 redirect

rkss

Registered Member
Joined
Aug 23, 2016
Messages
52
Reaction score
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?
 
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)."
 
this
RewriteRule ^(.*)$ http://apple.com/$1 [R=301,L]
 
Back
Top