Skip to main content
3 of 5
Removed superfluous text from title, and question.
dan
  • 15.2k
  • 11
  • 45
  • 52

How does a webmaster perform a proper redirect from one domain to another?

This is likely a very simple question with a very simple solution. I am just unable to find it it would seem. I have searched many different sites and they all have different answers. This site also has many answers that will work to redirect one domain to another but does not really answer anything more than that. No explanations, No hows and whys it works, why its the best, nothing. This does not answer the question though of which method is best. And I think this is something important that has been overlooked. At least for me.

I have been trying to learn Apache code. How to write Apache directives in .htaccess but still do not know how to write my own.

There are a few questions that are inherently present inside the main question. Those questions are:

  • What is the best way to perform this type of redirect? (Presumably a 301 Perma for SEO Best practices. You will retain 90%-99% of your link juice.)
  • At what level would you perform the redirect? Would you do it at the registrar level, in the cPanel/direct admin/etc, or would you perform this task in the .htaccess file? (Presumably the .htaccess file)
  • There are so many ways you can redirect from one domain to another how do we webmasters who can't read Apache directives know which is the best one to use? It can't be as cut and dry as "Just use any that works".

As there are multiple ways to accomplish this task, the task of redirecting one domain to another, the PRIMARY CONCERN of this question is what is the BEST WAY to accomplish this task, perform a redirect, and do it properly Below are a few of the examples I have seen (on this site and other sites):

1.

    ``Redirect 301 / http://www.newdomain.com/`

    ``Options +FollowSymLinks`

    ``RewriteEngine on`

    ``RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L`

    ``Options +FollowSymLinks`

    ``RewriteEngine on`

    ``RewriteCond %{HTTP_HOST} \olddomain.com$`

    ``RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]`

    `Options +FollowSymlinks`

    ``RewriteEngine On`

    ``RewriteCond %{HTTP_HOST} ^olddomain.com [NC]`

    ``RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]`


    ``RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC]`

    ``RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]`

    ``RewriteEngine on`

    ``RewriteCond %{HTTP_HOST} !^www.your_domain.com$`

    ``RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]`

Your assistance in this matter is priceless I have been trying to get a straight answer to this question for months. Even other people I see ask this question or questions similar receive the same answer even though our problems are sightly different or largely different. If you can, when you answer this, please explain to me why the redirect method you choose to answer with is the best one, why it's the best, and how it works,. Please break down the Apache directive so that myself, and other who come after me understand not just how to copy and paste a redirect but the particulars as well.